繁体   English   中英

仅在IE9上存在的ajax调用中拒绝访问

[英]Access denied in ajax call only existing on IE9

使用Xmlhttprequest进行ajax调用时遇到此问题。 我在Firefox,Chrome,Safari上测试代码,它们都运行良好。 只有IE上存在的问题,我使用的版本是9.有些人说我应该启用跨域支持。 实际上,我将Access-Control-Allow-Origin:*添加到http响应头中。 有任何想法吗? 谢谢。

我的代码是:

var xhr = new XMLHttpRequest();
var query = queryString.pageName.abbr + "="
        + encodeURIComponent(queryString.pageName.value) + "&"
        + queryString.pageURL.abbr + "="
        + encodeURIComponent(queryString.pageURL.value);
var getURL = "http://localhost:10001/test?" + query;

xhr.open('GET', getURL, false);
var result;
xhr.onreadystatechange = function() {
    var responseBody;
    if (xhr.readyState == 2) { // headers and status received
        alert(xhr.status);
    } else if (xhr.readyState == 4) { // full body received
        result = xhr.responseText;
    }
};
xhr.send(null);

这里有人有同样的问题: http//css-tricks.com/forums/discussion/17449/xmlhttprequest-not-working-in-ie9/p1 也许这会有所帮助: http//msdn.microsoft.com/en-us/library/cc288060 我也会像其他人一样推荐使用jQuery。 他们考虑这些问题: http//bugs.jquery.com/ticket/8283

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM