Error posting 'form' data in jqGrid in JSON format. What is correct synthax?

时光毁灭记忆、已成空白 提交于 2020-01-06 04:36:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!