Reputation: 30158
I'm trying to set up a website to run on the local file system and call an XML file, but I'm getting access control origin errors:
Origin null is not allowed by Access-Control-Allow-Origin.
I've tried switching the datatype to jsonp and setting crossdomain to true:
$j.ajax({
crossdomain: true,
url: 'xml/vehicles.xml',
dataType: "jsonp",
success: function( vehicleXML ) {
supertree.parseVehicles($j(vehicleXML).find("vehicles"), null);
supertree.vehiclesLoaded = true;
if(supertree.scenesLoaded) supertree.ready();
}
});
But it doesn't work. Any idea on how to accomplish this? Preferably without a proxy?
Upvotes: 1
Views: 2070
Reputation: 207501
Same origin policy prevents you have accessing the data. Either the server you are requesting data from needs to enable CORS or you need to use a proxy on your server to get the data from the other server.
Other option is to change the XML data into a JSONP format. It is not as easy as telling jQuery to make a JSONP request. The data formats are totally different and the server has to return that format, the JavaScript cannot do anything about it.
Upvotes: 2