从未达到 JQuery Ajax 成功

Tal*_*lon 2 jquery

我有一个这样的 AJAX 语句:

$.ajax({
            type: "POST",
            dataType: 'json',
            url: "DBDeleteList.php",
            data: {listID: listID},
            success: function(html){
                /* Succesfully Updated DB */
                alert( 'Saved!' );
                $(this).parents('li').remove();
                $('#sortableLoader').load('index.php #sortableMenu');
            }
});
Run Code Online (Sandbox Code Playgroud)

它工作正常并触发 PHP 文件和所有内容,数据库修改正常工作。

唯一的问题是“成功:”部分永远不会触发,即使它成功了。

感谢您提供任何提示。

joh*_*les 5

你有一个你没有看到的返回错误。您正在正确地发布到 php,但是无论您在发布后返回什么,您的 ajax 调用都不喜欢。在您的成功功能之后包括这样的东西来调试:

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);
    }
}
Run Code Online (Sandbox Code Playgroud)

我也会用萤火虫来帮助看看发生了什么