JavaScript Ajax (jQuery.post) 奇怪的错误:state =“rejected”

Rya*_*ard 3 javascript ajax jquery google-chrome jqxhr

所以我一直在尝试调试我的 jQuery.post() 调用,并且得到了一些奇怪的响应。我被困在下一步该做什么,如果有人有任何建议,我将非常感激。

<script type="text/javascript">
var debugresp;
var debugpost;
$("#scan .scanSide button.startScan").click(function() {
    // ...
    console.log("Scanning...");
    debugpost = $.post(
        "scan/scan.php",
        {
            "side": side
        },
        function(response) {
            console.log(response);
            /*...*/
        },
        "xml"
    );
    console.log("Sent data...");
});
<script>
Run Code Online (Sandbox Code Playgroud)

外部的两个console.log()调用$.post工作正常,页面200 OK在“网络”选项卡(调试工具/Chrome)下返回有效数据,但内部console.log(response)从未触发。

如果您注意到的话,我保存了来自 的退货$.post

// JavaScript console, while page hasn't returned yet
debugpost.state()
// > "pending"
// After the page returns, and console.log(response) hasn't been called
debugpost.state()
// > "rejected"
Run Code Online (Sandbox Code Playgroud)

我从未尝试过处理 中的问题jQuery.post,但我不希望从jqXHR中返回的 中“拒绝” $.post

有人可能对如何解决这个问题有更多的调试建议或建议吗?

资源:
jqXHR jQuery.post (...)

Rya*_*ard 5

问题已解决:我试图解析无效的 XML。

对于阅读本文的其他人,请尝试 jqXHRfail(function(jqXHR, textStatus, errorThrown)进行调试。