简体   繁体   中英

Cross site AJAX without JSONP?

Is there any way to do a cross site AJAX request without requiring JSONP?

In my situation, I need to pull data from a third-party resource, however it is not formatted as JSON (is XML)

You'll need some proxy server side script. You make the request to your local server, which in turn will fetch it from a remote location.

The best explanation and the solutions can be found here: http://developer.yahoo.com/javascript/howto-proxy.html

Here's a php example from Yahoo: http://developer.yahoo.com/javascript/samples/proxy/php_proxy_simple.txt

Yes you can use CORS: http://www.nczonline.net/blog/2010/05/25/cross-domain-ajax-with-cross-origin-resource-sharing/ . It doesnt work in IE7 and Opera today. And lacks some features in IE8 ( http://caniuse.com/#search=CORS )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM