服务端:
应用命名空间
using System.Web.Services;
using System.Web.Script.Services;
代码:
[WebMethod(EnableSession=true)]
[ScriptMethod(UseHttpGet=false)]
public static string GetAllRecord()
{
//代码内容
}
[ScriptMethod(UseHttpGet=false)]
public static string GetAllRecord()
{
//代码内容
}
客户端:
$.ajax({
type: "POST",
contentType: "application/json",
url: "Default.aspx/MethodName",
data: "{}",
dataType: "json",
success: function(data) {
var result = eval(data.d);
},
error: function() {
alert("处理失败");
}
});
type: "POST",
contentType: "application/json",
url: "Default.aspx/MethodName",
data: "{}",
dataType: "json",
success: function(data) {
var result = eval(data.d);
},
error: function() {
alert("处理失败");
}
});