I’m trying to request data which is located on another domain/server, but I’m getting an exception when I try to send the request.
var request = new XMLHttpRequest();
request.open("GET", "http://www.w3schools.com/ajax/cd_catalog.xml", false);
request.send();
The error:
uncaught exception: [Exception… “Component returned failure code: 0x80004005 (NS_ERROR_FAILURE)” nsresult: “0x80004005 (NS_ERROR_FAILURE)”]
Is this the correct way to request content which isn’t on the same domain/server? Or is there some other way to accomplish this?
I’m testing this in firefox 8.0, but I’d like a solution that could work for all major modern browsers.
You can’t retrieve content from another domain directly. You can retrieve content via a server doing the job for you (proxy), or using something like JSONP. Check this wikipedia page.
For extra information on the subject, this page may be interesting