JSON 文件未全部捕获在 Jquery ajax 请求中
JSON file not all caught in a Jquery ajax request
我在通过 HTTP POST 方法发送 JSON 文件参数时遇到问题。
该文件已正确生成,但仅发送了一部分。
$("#catalogOfService").jqGrid('navGrid',"#catalogOfService_pager").jqGrid('navButtonAdd', '#catalogOfService_pager', {
caption: "Export to Excel",
onClickButton: function () {
var json = $("#catalogOfService").getRowData();
var name = "report_catalogue";
console.log(json);
$.ajax({
type: "POST",
async: false,
url: "ExportCatalogueExcell.php",
data: {
name: name,
data: json,
},
success: function(result)
{
},
success: function(e){
setTimeout(function() {
console.log(yeah);
window.open("../tmp/" + name + '.csv');
}, 1000);
}
});
}
});
您可能需要更新此部分:
data: JSON.stringify(json)
JSON.stringify()
将 JavaScript 值转换为 JSON 字符串,换句话说,它将 JavaScript 对象转换为 JSON 文本并存储JSON 字符串中的文本。而且,此 JSON 文本是您在 POST
请求中需要的数据。
我在通过 HTTP POST 方法发送 JSON 文件参数时遇到问题。 该文件已正确生成,但仅发送了一部分。
$("#catalogOfService").jqGrid('navGrid',"#catalogOfService_pager").jqGrid('navButtonAdd', '#catalogOfService_pager', {
caption: "Export to Excel",
onClickButton: function () {
var json = $("#catalogOfService").getRowData();
var name = "report_catalogue";
console.log(json);
$.ajax({
type: "POST",
async: false,
url: "ExportCatalogueExcell.php",
data: {
name: name,
data: json,
},
success: function(result)
{
},
success: function(e){
setTimeout(function() {
console.log(yeah);
window.open("../tmp/" + name + '.csv');
}, 1000);
}
});
}
});
您可能需要更新此部分:
data: JSON.stringify(json)
JSON.stringify()
将 JavaScript 值转换为 JSON 字符串,换句话说,它将 JavaScript 对象转换为 JSON 文本并存储JSON 字符串中的文本。而且,此 JSON 文本是您在 POST
请求中需要的数据。