jqgrid howto send all rowData in json format to server?
how to send jqGrid data in json format to server? DO I have to use any external library or script to achieve that?
Thanks!
update1: extra licensePlateNumber
should not be there
[
{
"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"
}
]
Your approach from your other question is OK, but jQuery.ajax
has problems to serialize arrays. The most reliable and standard way (see here and here as examples) which I see is to serialize all jqGrid data to JSON (for example with respect of JSON.stringify function:
$("#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");
}
});
});
the names of parameters jgGridData
, customData
and so on, you can choose whatever you like.
精彩评论