码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2015-07-31 17:59:16      阅读:114      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!