请求的JSON解析失败 [英] Requested JSON parse failed
本文介绍了请求的JSON解析失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于某种原因,下面的ajax代码存在解析错误.我怎么能找到问题所在,和/或有人可以看到问题所在?
By some reason there's a parsing error with the ajax code below. How could I find out what it is, and/or can someone see what's wrong?
$('#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);
}
}
});
}
推荐答案
数据:{json:order} ...格式不正确...
data: { json: order } ... it's not well formatted...
这篇关于请求的JSON解析失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文