jqGrid使用json调用WebService(asmx)

我有一个jqGrid设置,使用application / json的内容类型发布到URL:

$("#jqCategoryGrid").jqGrid({ datatype: "json", mtype: 'POST', url: "Webservices/TroubleTicketCategory.asmx/getCategoryData", ajaxGridOptions: { contentType: 'application/json; charset=utf-8' }, // **UPDATE - This is the fix, as per Oleg's response** serializeGridData: function (postData) { if (postData.searchField === undefined) postData.searchField = null; if (postData.searchString === undefined) postData.searchString = null; if (postData.searchOper === undefined) postData.searchOper = null; //if (postData.filters === undefined) postData.filters = null; return JSON.stringify(postData); }, }); 

问题是jqGrid仍在尝试使用非json格式传递参数,因此我收到错误“无效的JSON原语”

有没有办法指示jqGrid使用Json序列化数据?

谢谢

UPDATE

我在我的问题中编辑了提供的源代码以包含我使用的修复程序,该修复程序来自Oleg的回复。

您应该包含已发布数据的JSON序列化,例如关于json2.js,可以从http://www.json.org/js.html下载:

 serializeRowData: function (data) { return JSON.stringify(data); }