Is this a valid jquery getJSON call?

Posted by Pandiya Chendur on Stack Overflow See other posts from Stack Overflow or by Pandiya Chendur
Published on 2010-05-04T10:41:32Z Indexed on 2010/05/04 10:48 UTC
Read the original article Hit count: 291

Filed under:
|
|
|

I am using jquery getJSON with asp.net mvc controller... I cant able to get it work....

 public JsonResult GetMaterials(int currentPage,int pageSize)
 {
   var materials = consRepository.FindAllMaterials().AsQueryable();
   var results = new PagedList<MaterialsObj>(materials, currentPage-1, pageSize);
   return Json(results);
 }

and i am calling this with,

$.getJSON('Materials/GetMaterials', "{'currentPage':1,'pageSize':5}",
 function(data) {
    });

This call doesn't seem to work....

when inspected through firebug i found this,

The parameters dictionary contains a null entry for parameter 
'currentPage' of non-nullable type 'System.Int32' for method 
'System.Web.Mvc.JsonResult GetMaterials(Int32, Int32)' in 
'CrMVC.Controllers.MaterialsController'. To make a parameter optional its type
 should be either a reference type or a Nullable type.<br>
 Parameter name: parameters

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about getjson