HjalmarCarlson
HjalmarCarlson

Reputation: 868

Receiving XML responses cross domain (XHR or Websockets)

I'm searching for a solution to pull an XML response from Google's ad service DoubleClick. If I had it my way I would just use XHR to handle the response but it's in violation of the Same Origin Policy. So I was looking into websockets as an alternative solution since it seems to handle same origin policies differently.

Can anyone give me some insight on what the best approach would be for handling this XML response client side?

Upvotes: 0

Views: 229

Answers (3)

SD05
SD05

Reputation: 51

Take a look at xReader

<script src="http://kincrew.github.com/xReader/xReader.full.js"></script> 
<script type="text/javascript"> 
xReader("http://www.yahoo.com/", function(data) { 
    alert(data.content); 
})
</script>

It's simple!

xReader has a difference from other with using YQL. xReader isn't blocked by robots.txt.

Upvotes: 1

HjalmarCarlson
HjalmarCarlson

Reputation: 868

I actually found a great plugin that will handle everything client side: https://github.com/padolsey/jQuery-Plugins/tree/master/cross-domain-ajax/

Upvotes: 0

SoWhat
SoWhat

Reputation: 5622

The simplest possible way would be to have a local script that fetches this domain

 behold getter.php
 $url="http://service-url.com/falana-dinka.xml"
 echo file_get_contents($url)

Now you can send an XHR to this file(getter.php) and parse the response on client side. You can even process the data and send only necessary content to the client(thus reducing load on it)

If the service you are looking for offers a jsonp api, you can directly utilize it

Upvotes: 0

Related Questions