xmlhttprequest status 0 statusText“未知” - 安全证书?

发布于 2024-10-08 03:00:59 字数 934 浏览 3 评论 0原文

这是在 IE 的 javascript 中完成的:所以我继续使用 xmlhttprequest 进行工作,我想我终于明白了如何很好地使用它,以便在所有情况下使用它。好吧,当返回的状态为 0 并且 statusText 为“未知”时,我什至不知道该怎么想。因此,我创建一个 XMLHttpRequest 并将其推送到一个数组中,这个特定的数组位于 requests[0] 中。这是相关代码。

this.requests[0].open("GET", "https://" + this.address, true);
//This is just something I put in that I found that would supposedly 
//Fix the problem.
this.requests[0].setRequestHeader("Content-type", "text/xml");
this.requests[0].send();
function onReadyStateChange1() {
    if (4 == me.requests[0].readyState) {
        if (me.requests[0].status == 200) {
            //Once I get this working I'll have a statement to use          
            //XML for response if possible.
            var response = me.requests[0].responseText;
            return response;            
       }
    }
}

我似乎不明白为什么。 XMLHttpRequest 是否可能无法处理安全的 http 连接?或者,正如我认为更有可能的是,由于网站的安全证书存在问题,XMLHttpRequest 拒绝获取它?或者是别的什么?

This is being done in javascript for IE: So I continue to do work with xmlhttprequest and I THOUGHT I finally understood how to use it well enough to use it in all cases. Well I don't even know what to think when the status being returned is 0 and the statusText is "unknown". So I create an XMLHttpRequest and push it onto an array, this particular one is in requests[0]. Here's the relevant code.

this.requests[0].open("GET", "https://" + this.address, true);
//This is just something I put in that I found that would supposedly 
//Fix the problem.
this.requests[0].setRequestHeader("Content-type", "text/xml");
this.requests[0].send();
function onReadyStateChange1() {
    if (4 == me.requests[0].readyState) {
        if (me.requests[0].status == 200) {
            //Once I get this working I'll have a statement to use          
            //XML for response if possible.
            var response = me.requests[0].responseText;
            return response;            
       }
    }
}

I can't seem to figure out why. Can XMLHttpRequest simply somehow not handle secure http connections? Or is it, as I believe is far more likely, that because there is a problem with the website's security certificate the XMLHttpRequest refuses to get it? Or is it something else?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

万劫不复 2024-10-15 03:00:59

有问题的代码可能会引发安全异常。

是的,协议是 Origin 的一部分;您无法在 IE 中使用 XMLHTTPRequest 发出跨域请求。请尝试使用 XDomainRequest 对象。

The code in question is probably throwing a security exception.

Yes, the Protocol is a part of the Origin; you cannot make cross-origin requests with XMLHTTPRequest in IE. Try the XDomainRequest object instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文