3 ways to make a cross-domain request in Javascript

流过昼夜 提交于 2020-01-06 05:48:06

问题


I already know 2 ways (proxy using php and including an external javascript file). What is another way?


回答1:


You can use Access-Control-Allow-Origin: * in the headers coming from the server on the other domain.

That relies on the browser being modern, however. Won't work on IE older than 8.

See https://developer.mozilla.org/En/HTTP_access_control




回答2:


There is also Cross-Document Messaging combined with regular XHR.

An example of this can be seen on the easyXDM example page : http://consumer.easyxdm.net/current/example/xhr.html



来源:https://stackoverflow.com/questions/5812538/3-ways-to-make-a-cross-domain-request-in-javascript

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