2

我正在尝试从 HTTPS 网站到 HTTP 端点进行 jquery Ajax 调用。

我收到“混合内容”错误:

Mixed Content: The page at 'https://...' was loaded over HTTPS, 
but requested an insecure XMLHttpRequest endpoint 'http://...'. 
This request has been blocked; the content must be served over HTTPS.

问题是我对 Ajax 事件“完成”的回调没有触发,尽管根据 jquery 页面(https://api.jquery.com/Ajax_Events/):

complete (Local Event)
This event is called regardless of if the request was successful, or not. 
You will always receive a complete callback, even for synchronous requests.

这是我的代码:

$.ajax({
    type: "POST",
    url: url,
    data: data,
    complete: function (results) {
        // Stuff in here is not executed on "Mixed Content" error
    }
});

有没有其他方法可以捕获错误?阿贾克斯似乎没有能力。

编辑 我知道这个问题:HTTP Ajax Request via HTTPS Page

我的问题不是“为什么会发生错误”,我希望它会发生。我的问题是,由于 jQuery 的“完成”事件失败,我如何才能捕捉到这种类型的错误。

4

0 回答 0