Ext在firefox中出现uncaught exception.....(XMLRequest.Open)的异常!
这是因为firefox安全性强,不允许跨域调用。
Firefox 要取消XMLHttpRequest的跨域限制的话,
第一是从 about:config 里设置 signed.applets.codebase_principal_support = true; (地址栏输入about:config 即可进行firefox设置)
第二就是在open的代码函数前加入类似如下的代码:
try { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); } catch (e) { alert("Permission UniversalBrowserRead denied."); }
<script type="text/javascript" language="javascript">
// Error: uncaught exception: Permission denied to call method XMLHttpRequest.open
var http_request = false;
function makeRequest(url, parameters) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
} catch (e) {
alert("Permission UniversalBrowserRead denied.");
}
http_request = false;
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
if (!http_request) {
alert('Cannot create XMLHTTP instance');
return false;
}
http_request.onreadystatechange = alertContents;
http_request.open('GET', url + parameters, true);
http_request.send(null);
}
function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
var string = http_request.responseText;
alert(string);
} else {
alert('There was a problem with the request.');
}
}
}
function updateweather() {
makeRequest('http://www.wunderground.com/auto/rss_full/global/stations/16239.xml', '');
}
</script>
<input type="button" name="button" value="GET XML"
onclick="javascript:updateweather();">