首页 > Web开发 > 详细

jquery ajax asp.net

时间:2015-08-05 18:00:15      阅读:226      评论:0      收藏:0      [点我收藏+]

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 "您还没有发送短信验证码,或已过期";
}
}

jquery ajax asp.net

原文:http://www.cnblogs.com/waiwai1015/p/4705060.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!