如何传递我的服务端点参数? (本例中的页面大小)
我的 .asmx 服务方法如下所示:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public List<Object> GetData(int pageSize)
{
}
当我像这样通过 jQuery 调用它时:
$.ajax({
type: "POST",
url: "test.asmx/test123",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
},
error: function(msg) {
}
});
最佳答案
您可以将其作为 json 传递:
$.ajax({
type: "POST",
url: "test.asmx/test123",
data: "{'pageSize':'14'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
},
error: function(msg) {
}
});
关于c# - 通过 jQuery 调用 asmx 服务时,如何传递参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2806340/