简体   繁体   English

Ajax请求子域

[英]Ajax request subdomain

Is there a way to get ajax requests from http://foobar.com to snatch data from pages such as http://sub1.foobar.com/choco.php ? 有没有一种方法可以从http://foobar.com获取ajax请求以从诸如http://sub1.foobar.com/choco.php之类的页面中抢夺数据?

It seems subdomain requests are still not allowed via javascript 似乎仍然不允许通过javascript访问子域请求

If the data is not sensitive, you may use JSONP (JSON with Padding) as an alternative. 如果数据不敏感,则可以使用JSONP(带填充的JSON)作为替代。

http://en.wikipedia.org/wiki/JSON#JSONP http://en.wikipedia.org/wiki/JSON#JSONP

JSONP(如Andrew 所述 )或代理脚本

您可以将Access-Control-Allow-Origin标头用于现代浏览器,并将请求包装在本地域中以用于古董浏览器。

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

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