gpt4 book ai didi

jquery - jqgrid如何将json格式的所有rowData发送到服务器?

转载 作者:行者123 更新时间:2023-12-03 22:44:22 25 4
gpt4 key购买 nike

如何将jqGrid数据以json格式发送到服务器?我必须使用任何外部库或脚本才能实现这一目标吗?

谢谢!

update1:不应有额外的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"
}
]

最佳答案

您的方法来自 other question没问题,但是 jQuery.ajax 在序列化数组时遇到问题。我看到的最可靠和标准的方法(参见herehere作为示例)是将所有jqGrid数据序列化为JSON(例如关于JSON.stringify函数:

$("#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");
}
});
});

参数名称jgGridDatacustomData等等,你可以随意选择。

关于jquery - jqgrid如何将json格式的所有rowData发送到服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3816874/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com