jquery调用asp.net的WebService
时间:2011-04-15 来源:一粒沙
asmx.cs
using System.Web.Script.Services;
[System.Web.Script.Services.ScriptService]
public class test : System.Web.Services.WebService
{
[ScriptMethod(UseHttpGet = true)]
public void testMethod(int id)
{
}
}
js
$.ajax({
url: 'test.asmx/testMethod',
dataType: "json",
data: "id=2",
beforeSend: function(x) {
x.setRequestHeader("Content-Type", "application/json; charset=utf-8");
},
success: function(json) {
var o = eval("(" + json.d + ")");
callBack(o);
}
});
相关阅读 更多 +