I have spent hours in this problem and my fellows couldn’t help me out. He said it might be a cross-site scripting problem, probably my system setting cause this problem because the script runs well on my fellow’s machine.
Below is the simple case:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var req = new XMLHttpRequest();
var url = "http://www.javascriptkit.com/dhtmltutors/javascriptkit.json";
req.open("GET", url, false);
try {
req.send();
} catch (e) {
alert("ERROR: " + e);
}
</script>
</head>
<body>
</body>
</html>
Execute the code, an error shows up:
ERROR: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE)" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://firebug/content/console/commandLineExposed.js :: <TOP_LEVEL> :: line 156" data: no]
I ran this code on my localhost, firebug console and jsFiddle, all of them are not working.
I am sure my local server is running well since the test script alert("works") is working.
Anyone can help me out here. Is this a system setting problem? Thanks!
XMLHttpRequestto a different domain? Unless they set a headerAccess-Control-Allow-Originin their response, you won’t be able to get at it. In Opera (well, version 11.64 at least), you won’t be able to get at it, regardless.I think your colleague’s machine is insecurely configured.