问题
I am trying to post data to the action method in the postData section in jqGrid like this, but get an error, any ideas?
postData: { species: function()
{
return JSON.stringify($("form"));
},
I can tell you that this format below does work but it is not JSON:
postData: { species: $("form").serialize() },
回答1:
Probably you should use jQuery.serializeArray instead of jQuery.serialize:
postData: {
species: function() {
return JSON.stringify($("form").serializeArray());
}
}
See also the answer for some more version of data conversion of the data returned from $("form").serializeArray()
before calling of JSON.stringify
.
来源:https://stackoverflow.com/questions/9651939/error-posting-form-data-in-jqgrid-in-json-format-what-is-correct-synthax