如何将json格式的jqGrid数据发送到服务器?我是否必须使用任何外部库或脚本来实现?
谢谢!
update1 :多余的licensePlateNumber不应该在那里
licensePlateNumber
[ { "licensePlateNumber": "" }, { "licensePlateNumber": "0000000000000029000721804", "sku": "795127", "description": "", "caseQuantity": "24", "isHeld": "false", "expirationDate": "Jul 22, 2010 12:00:00 AM" }, { "licensePlateNumber": "0000000000000029000722323", "sku": "795127", "description": "", "caseQuantity": "24", "isHeld": "false", "expirationDate": "Jul 22, 2010 12:00:00 AM" }, { "licensePlateNumber": "0000000000000029000722669", "sku": "795127", "description": "", "caseQuantity": "24", "isHeld": "false", "expirationDate": "Jul 22, 2010 12:00:00 AM" } ]
您从另一个问题出发的方法还可以,但是jQuery.ajax在序列化数组方面遇到问题。我看到的最可靠,最标准的方法是将所有jqGrid数据序列化为JSON(例如,关于JSON.stringify函数:
jQuery.ajax
$("#sendButton").click(function(){ var gridData = jQuery("#list").getRowData(); var postData = JSON.stringify(gridData); alert("JSON serialized jqGrid data:\n" + postData); $.ajax({ type: "POST", url: "/cpsb/internalOrderList.do", data : { jgGridData: postData, customData: "bla bla" }, dataType:"json", contentType: "application/json; charset=utf-8", success: function(response, textStatus, xhr) { alert("success"); }, error: function(xhr, textStatus, errorThrown) { alert("error"); } }); });
参数的名称jgGridData,customData等等,您可以选择任何您喜欢的。
jgGridData
customData