简体   繁体   English

没有JSONP的跨站点AJAX?

[英]Cross site AJAX without JSONP?

Is there any way to do a cross site AJAX request without requiring JSONP? 有没有办法在不需要JSONP的情况下进行跨站点AJAX请求?

In my situation, I need to pull data from a third-party resource, however it is not formatted as JSON (is XML) 在我的情况下,我需要从第三方资源中提取数据,但它没有格式化为JSON(是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 最好的解释和解决方案可以在这里找到: 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 这是雅虎的一个php示例: 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/ . 是的,您可以使用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. 它今天在IE7和Opera中不起作用。 And lacks some features in IE8 ( http://caniuse.com/#search=CORS ) 并缺少IE8中的一些功能( http://caniuse.com/#search=CORS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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