首页 > Web开发 > 详细

ajax访问当前页面后的 [WebMethod]描述的方法

时间:2015-07-31 17:57:14      阅读:304      评论:0      收藏:0      [点我收藏+]

脚本:

function show() {
$.ajax({
type: "post",
async: false,
contentType: "application/json",
url: "/WebForm1.aspx/GetStr",
data: ‘{"name":"txxx"}‘,
dataType: "json",
success: function (result) {
debugger;
var data = $.parseJSON(result.d);
alert(data.name);
}
});
}

后台:

[WebMethod]
public static string GetStr(string name)
{
  return "{\"name\":\"" + name + "\"}";
}

注意:[WebMethod(EnableSession=true)] 在方法内可以使用Session

ajax访问当前页面后的 [WebMethod]描述的方法

原文:http://www.cnblogs.com/xsj1989/p/4692762.html

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