Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Xml Data Cross-Domain with JQuery

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?

like image 523
Dänu Avatar asked Feb 16 '26 07:02

Dänu


2 Answers

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.

like image 135
jAndy Avatar answered Feb 17 '26 20:02

jAndy


You need to use JSONP.

like image 37
x1a4 Avatar answered Feb 17 '26 22:02

x1a4



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!