简体   繁体   English

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

[英]Is this a valid jquery getJSON call?

I am using jquery getJSON with asp.net mvc controller... I cant able to get it work.... 我正在使用jquery getJSON与asp.net mvc控制器......我无法让它工作....

 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

Typically, data should be an object: 通常, data应该是一个对象:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM