jQuery AJAX – Get XML Data Cross-Domain

ajaxcross-domainjquery

Is there a way to load XML Data Cross-Domain with JQuery (= client side)?

$.get('http://otherdomain.com/data.xml', function(xml) { }

The above doesn't work – do I have to rely on JSONP, or is there a way to load XML?

Best Answer

No way to load XML. So yes, using "standard" xmlhttprequests you need JSONpadding.

If the server supports "Cross-Origin Resource Sharing (CORS)" you can easily receive data from a foreign domain. That means, you have to add a custom header into your XmlHttpRequest ('Origin') and the server decides if it does allow the request or not.