zoukankan      html  css  js  c++  java
  • jquery ajax asp.net

    function yanzhengma() {
    var msgma = $("#txtma").val();
    $.ajax({

    type: "Post",
    url: "WebForm3.aspx/RequestMethod2",
    data: "{'msg':'" + msgma + "'}",
    contentType: "application/json;charset=utf-8", // 这句可不要忘了。
    dataType: "json",
    success: function (res) {
    alert(res.d); // 注意有个d,至于为什么通过chrome看响应吧,O(∩_∩)O。
    },
    error: function (xmlReq, err, c) {
    alert(err);
    }
    });
    }

    <input type ="text" id="txtma" />
    <input type ="button" onclick="yanzhengma()" value="确定" />

    [WebMethod]
    public static string RequestMethod2(string msg)
    {
    try
    {
    string ma = HttpContext.Current.Session["ma"].ToString();
    if (ma == msg)
    {
    return "yes";
    }
    else
    {
    return "no";
    }
    }
    catch
    {
    return "您还没有发送短信验证码,或已过期";
    }
    }

  • 相关阅读:
    001-进程与线程
    mysql优化(11)
    mysql优化(十)
    mysql优化(九)
    mysql优化(八)
    mysql优化(七)
    mysql优化(六)
    mysql优化(五)
    mysql优化(四)
    mysql优化(二)
  • 原文地址:https://www.cnblogs.com/waiwai1015/p/4705060.html
Copyright © 2011-2022 走看看