【问题标题】:XDomainRequest not giving response while status is 200XDomainRequest 在状态为 200 时未给出响应
【发布时间】:2012-09-18 11:06:31
【问题描述】:

XDomainRequest 在状态为 200 时未给出响应

var httpRequest = new XDomainRequest();
httpRequest.open('POST', url, true);
httpRequest.send(xmlDocument);
alert(httpRequest.responseText);
return httpRequest;

它给出的响应文本为空。请指导我在哪里失踪。

【问题讨论】:

    标签: javascript ajax request response xdomainrequest


    【解决方案1】:

    尝试做:

    var httpRequest = new XDomainRequest();
    httpRequest.onload=function() {
        alert(httpRequest.responseText);
    }
    httpRequest.open('POST', url, true);
    httpRequest.send(xmlDocument);
    

    【讨论】:

    • 如果应用它会显示错误。 httpRequest.onerror = function() { alert("错误!");警报(httpRequest.responseText); };
    • 您的服务器是否为返回的响应返回正确的“text/xml”内容标头类型,如果它的 XML 数据..?
    • 您的服务是否发送了带有值 * 的 Access-Control-Allow-Origin HTTP 响应标头,或者调用页面的确切来源...?
    • 我正在尝试如何发送 Access-Control-Allow-Origin HTTP 响应标头
    • 我不知道 java 或 jsp,但似乎这些可能有助于设置标题:: restlet-discuss.1400322.n2.nabble.com/…padcom13.blogspot.com/2011/09/…
    猜你喜欢
    • 2015-11-16
    • 2016-11-29
    • 2015-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-31
    • 1970-01-01
    • 2016-12-14
    相关资源
    最近更新 更多