如何通过INT值从jQuery的ASP.NET页面的方法呢?
-
23-09-2019 - |
题
我使用jQuery的ASP.NET页面的方法。这是我的代码,
$.ajax({
type: "POST",
url: "Default.aspx/GetRecords",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
和ASP.NET页面的方法是,
[WebMethod]
public static string GetRecords(int currentPage,int pagesize)
{
// my logic here
}
如何从jQuery的通作currentPage
和pagesize
值?
解决方案
我得到它的工作。我的数据部分必须是
data: "{'currentPage':1,'pagesize':5}",
其他提示
你尝试只是:
$.ajax({
type: "POST",
url: "Default.aspx/GetRecords",
data: {"currentPage": 1, "pageSize": 100},
contentType: "application/json; charset=utf-8",
dataType: "json",
尝试这
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
data: "{ currentPage: '" +parseInt( $('#currentpage').val()) + "',pageSize:'"+parseInt( $('#pagesize').val()) +"'}",
url: "Default.aspx/GetRecords",
dataType: "json",
success: function (data) {
$("#result").html(data.d);
}
});
不隶属于 StackOverflow