This topic has been discussed in different flavors before, but I have not yet found a solution that works for me. I'm using jquery 1.7.1.
I have a REST style web service that can return both JSON and XML, but for this project I need to use the XML endpoint. To get around the cross domain restrictions, I've created a transparent proxy using Perl's HTTP::Proxy. This proxy works as a breeze since I can talk to it with HTTP GET clients from anywhere.
Since it is a transparent proxy, it relies on the Host header being set in the client request. My code looks like this:
$.ajax({
type: "GET",
crossDomain: true, // not needed I think
error: function() { alert('Failed ..'); },
url: "http://www.skiforeningen.no:8080/<remote REST URL>",
dataType: "xml",
headers: {'Host': 'remote REST host'},
success: parseXml,
});
Chrome is very explicit, and says
Refused to set unsafe header "Host"
and
XMLHttpRequest cannot load http://www.skiforeningen.no:8080/sted/Norge/Oslo/Oslo/Skansebakken/varsel.xml. Origin http://www.skiforeningen.no is not allowed by Access-Control-Allow-Origin
but both the proxy and the HTML page with jquery sits on the host www.skiforeningen.no.
FF also refuses to set the Host header (apparently) since the error event handler is triggered.
Thanks,