这是一个有效的jquery getJSON调用吗?

时间:2010-05-04 10:41:33

标签: jquery asp.net-mvc controller getjson

我正在使用带有asp.net mvc控制器的jquery getJSON ......我无法让它工作....

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

我打电话给,

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

此调用似乎不起作用....

通过萤火虫检查我发现了这个,

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

1 个答案:

答案 0 :(得分:2)

通常,data应该是一个对象:

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