How to get ajax response from other domain?

风流意气都作罢 提交于 2019-12-03 21:27:58

If what you mean by "without modifying server side's code" is not modifying the server of the data source, then you can have your own proxy server (basically making your own YQL server) to read the remote data. This is possible because the server-side is not bound to the Same-Origin Policy.

So you can AJAX your server, then let your server read the remote server using some form of wget, curl or fopen, and return what was retrieved:

Remote server <- fopen, curl or wget -> your server <- AJAX -> browser

You can use a HTML 5 feature which is postMessage to do cross domain calls. Again it is not supported in all the browsers. Look at the following link for implementation: Cross domain call using postMessage

Kishore

You can use the iframe receiver pattern. It's an old technique. See Secure Cross-Domain Communication in the Browser by Danny Thorpe on MSDN. You dont have to use JSONP but still can make cross-domain calls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!