views:

208

answers:

2

I am using asp.net page methods with jquery..... Here is my code,

$.ajax({
      type: "POST",
      url: "Default.aspx/GetRecords",
      data: "{}",
      contentType: "application/json; charset=utf-8",
      dataType: "json",

and asp.net page method is,

[WebMethod]
public static string GetRecords(int currentPage,int pagesize)
{
    // my logic here
}

How to pass values for currentPage and pagesize from jquery....

A: 

Did you try just:

$.ajax({
    type: "POST",
    url: "Default.aspx/GetRecords",
    data: {"currentPage": 1, "pageSize": 100},
    contentType: "application/json; charset=utf-8",
    dataType: "json",

?

Dean Harding
@codeka that doesn't seem to work...
Pandiya Chendur
@codeka that method doesn't get called..
Pandiya Chendur
@codeka when inspected through firebug it `500 internal server error`
Pandiya Chendur
+5  A: 

I got it working my data section must be

data: "{'currentPage':1,'pagesize':5}",

Pandiya Chendur