Best method to get over cross domain in javascript

喜你入骨 提交于 2020-01-17 07:31:17

问题


i have in my localhost:8111 a restlet app running. This app have a ServerResource that respond http requests from a javascript api that i'm doing.

This Javascript api is running in my apache in localhost, and i want to do http request to the localhost:8111, but i can't for the cross domain problem.

The restlet response in json, which solution is the best in this case?

Thanks!


回答1:


The same as any other case.

  • CORS if you want control and are willing to sacrifice some cross-browser support.
  • JSON-P if you can live with GET only requests and no security over which sites can trigger the request
  • A proxy on the same origin if you don't need the final server to get credentials directly from the client


来源:https://stackoverflow.com/questions/8136107/best-method-to-get-over-cross-domain-in-javascript

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