由于某种原因,下面的 ajax 代码出现解析错误。我怎样才能知道它是什么,和/或有人可以看到出了什么问题?
$('#listElements').sortable({
//revert: true,
update: function(event, ui) {
var order = [];
$('.listObject li').each(function (e) {
order.push($(this).attr('id'));
});
$.ajax({
type: "POST",
url: "index.php?",
dataType: "json",
data: { json: order }, error: function(jqXHR, exception) {
if (jqXHR.status === 0) {
alert('Not connect.\n Verify Network.');
} else if (jqXHR.status == 404) {
alert('Requested page not found. [404]');
} else if (jqXHR.status == 500) {
alert('Internal Server Error [500].');
} else if (exception === 'parsererror') {
alert('Requested JSON parse failed.');
} else if (exception === 'timeout') {
alert('Time out error.');
} else if (exception === 'abort') {
alert('Ajax request aborted.');
} else {
alert('Uncaught Error.\n' + jqXHR.responseText);
}
}
});
}
最佳答案
data: { json: order } ...格式不正确...
关于jquery - 请求的 JSON 解析失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13033374/