我创建了一个名为proxy.cs的类,并在此添加了一个方法,现在想从jquery中调用它。那么我怎么做呢?课程代码是:
public class proxy : System.Web.Services.WebService
{
[System.Web.Services.WebMethod(BufferResponse = false)]
public string GetBigData()
{
return "hi welcome";//implementation code
}
}
以下脚本功能无效。
function test(){
$.ajax(
{
url: '/proxy/GetBigData',
type: 'POST',
contentType: 'application/json;charset=utf-8',
data: "{}",
success: function (response) {
},
failure: function (response) {
}
});
}
答案 0 :(得分:0)
使用以下Ajax代码
$.ajax({
type: "GET",
url: '/proxy/GetBigData',
data: null,
contentType: "application/json; charset=utf-8",
dataType: "json",
processdata: true,
success: function (data) {
console.log(data);
},
error: function (message) {
console.log("error", message);
}
});