【问题标题】:IE9 xdr.open() does not work -- what am I doing wrong?IE9 xdr.open() 不起作用——我做错了什么?
【发布时间】:2012-06-13 11:50:39
【问题描述】:

这是我的代码。

我知道它指向本地主机。但是,它应该为您提供 404。如果你能把它弄到404,你就领先我了。

我使用了 IE9 的调试控制台,并且可以在“xdr.open()”调用之前立即开始。

我在网络面板中看不到任何内容。请帮忙。

$('body').on('click','.click',function() {    
    if (window.XDomainRequest) {
            xdr = new XDomainRequest();

            xdr.onload = function() {
                xdr.contentType = "text/plain";
                alert('load');
            };

            xdr.onerror = function() {
                alert('error');                                      
            };

            xdr.onprogress = function() {
                alert('progress');
            };

            xdr.ontimeout = function() {
                alert('timeout');
            };
            xdr.timeout = 10000;


            alert('Preparing to open connection...');                
            xdr.open( 'GET', host + '/bookmarklet/saveData/' );
            alert('If you see this message, the connection is opened');

            xdr.send( ( s.hasContent && s.data ) || null );
            alert('If you see this message, the data has been sent!');
        }
});

编辑:更正了 xdr.setTimeout 周围的复制/粘贴中的错字——仍然不起作用?

【问题讨论】:

  • 另外,我的 php 文档中设置了 access-control-allow-origin: *,但 IE9 仍然显示“访问被拒绝”?

标签: ajax internet-explorer-9 cors


【解决方案1】:

我发送了两次 access-control-allow-origin: * 标头(一次在 .htaccess 中,一次在 php 脚本中)

使用 chromebug 检查“原始标题”而不仅仅是“标题”;)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-16
    • 2017-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多