0

I am looking for a way to make a request to an XML service from javascript.

Actually I am using JQuery, and I'm trying to use this plugin: http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/, but it doesn't work with XML.

There is an alternative way to consume JSON, which is JSONP, but it doesn't work with XML.

Every time I try to make a request to other site, with XML data, I get something like this:

Origin null is not allowed by Access-Control-Allow-Origin.

The other thing, I need to implement this without proxy, just solve it in client side.

hippietrail
  • 15,848
  • 18
  • 99
  • 158
todotresde
  • 1,770
  • 2
  • 19
  • 25
  • I use postMessage with Iframe for this type of stuff. You don't have to do anything special for headers on sending/receiving. postMessage is compatible with IE8 and all other modern browsers. – King Friday Mar 16 '12 at 16:42
  • YQL is not a possible solution. Need to be solved on client side – todotresde Mar 16 '12 at 16:49
  • I believe there's no way to do it without a proxy if the server doesn't support JSONP or CORS and you do not have access to the server. In fact if you look at the sidebar on the right of this window under the **Related** heading you will see many many similar questions. – hippietrail Mar 16 '12 at 17:40
  • Might be best to consider this question a duplicate of **[Ways to circumvent the same-origin policy](http://stackoverflow.com/questions/3076414/ways-to-circumvent-the-same-origin-policy)** - it seems to be the most canonical question of this topic. – hippietrail Mar 16 '12 at 17:51

2 Answers2

1

If you have access to the server and it happens to be apache then you can try add this into your VirtualHost

Header add Access-Control-Allow-Origin "http://yourdomain.com"
Manatok
  • 5,506
  • 3
  • 23
  • 32
  • Thanks for reply. Basically, I dont have access to the server where reside the application, and the server from where we consume services. Need to be solved on client. – todotresde Mar 16 '12 at 17:09
  • @todotresde: If you want a good answer you should tell us as many details as possible in your question. Whether you have access to the server or not is one of the most important details. – hippietrail Mar 16 '12 at 17:29
  • yes, that's why I use iframe communication with postMessage. The limitation is its not supported below IE8. – King Friday Mar 16 '12 at 17:31
1

Well, seems is not possible to do this when data is XML :(.

Thanks all!

todotresde
  • 1,770
  • 2
  • 19
  • 25