AJAX问题-FireFox中没有响应文本,但在IE中还可以 [英] AJAX Problem - No response text in FireFox, but ok in IE
问题描述
我正在对外部站点进行简单的AJAX调用.在IE中可以正常使用,但在Firefox中,不会返回响应文本.
I am making a simple AJAX call to an external site. It works ok in IE, but in Firefox, not response text is returned.
我认为响应可能与块状"有关,但我不确定.
I think it might have something to do with the response being "chunked", but I'm not sure.
有什么想法吗?谢谢.
<html>
<head>
<script type="text/javascript" charset="utf-8">
function loadXMLDoc() {
var xmlhttp;
var urlString = "http://drc.edeliver.com.au/ratecalc.asp?Pickup_Postcode=6025&Destination_Postcode=6055&Country=AU&Weight=100&Service_Type=STANDARD&Length=100&Width=100&Height=100&Quantity=2";
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
window.alert(xmlhttp.responseText);
}
}
xmlhttp.open("GET", urlString, true);
xmlhttp.send();
}
</script>
</head>
<body>
<span onclick="loadXMLDoc()">Click Me</span>
</body>
</html>
推荐答案
您的页面是否托管在 http://drc.edeliver.com.au 也可以吗?如果没有,那么您将无法对该URL进行XMLHttpRequest.这违反了基本的浏览器安全性,对于您的IE测试而言,它可能受到显式浏览器配置的抑制.
Is your page hosted at http://drc.edeliver.com.au also? If not, then you can't make an XMLHttpRequest to that URL. It's a violation of basic browser security which, for your IE tests, are probably suppressed by explicit browser configuration.
edit —我认为IE可以让本地安全区域"(或他们所说的任何地方)摆脱"Internet"区域页面所不允许的内容.
edit — I think IE lets the "local security zone" (or whatever they call it) get away with stuff that is not allowed for "Internet" zone pages.
这篇关于AJAX问题-FireFox中没有响应文本,但在IE中还可以的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!