jquery - 请求的 JSON 解析失败

标签 jquery ajax json parsing

由于某种原因,下面的 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/

相关文章:

jquery - Fancybox3 Youtube 视频

即使单击“确定”后,javascript 警报仍会连续触发

javascript - 为什么可警报换行符不起作用?

javascript - 当从移动设备长按我的网站图像时出现设计问题

javascript - 使用 XMLHttpRequest 解析 JSON 时返回空值

javascript - Wordpress 中带有单选按钮的 Ajax 后置过滤器

ajax - Grails从xhr获取文件

javascript - select2 为每个选项手动设置选项属性

json - 如何将json主体解码到 Camel 中的myclass列表

php - 为什么 jQuery.parseJSON 不接受换行符?