转载网址:https://www.cnblogs.com/xujingyang/p/5560646.html
转载网址2:https://jingyan.baidu.com/article/066074d66e1a41c3c21cb0c9.html
利用JQuery封装好的AJAX来请求aspx的后台方法,还是比较方便的,但是要注意以下几点:
1、首先要在方法的顶部加上[WenMethod]的特性(此特性要引入using System.Web.Services;命名空间)
2、其次方法一定要是静态(static)方法。
//带参数返回string方法
$.ajax({
type: "post",
url: "后台返回json数组.aspx/sayHi",
data: "{\"name\":\"小明\",\"age\":\"18\"}",
contentType: "Application/json;charset=utf-8",
success: function (msg) {
alert(msg.d);
}
})
contentTypeD的Application/json; 写成application/json 执行失败
很多作者都写的application 第一次用,不知道为什么