Cross-site XMLHttpRequest

前端 未结 3 1249
温柔的废话
温柔的废话 2020-11-29 02:37

I want to provide a piece of Javascript code that will work on any website where it is included, but it always needs to get more data (or even modify data) on the server whe

3条回答
  •  星月不相逢
    2020-11-29 02:57

    The easiest option for you would be to proxy the call through the server loading the javascript. So some.js would make a call to the hosting server, and that server would forward the request to abc.com.

    of course, if that's not an option because you don't control the hoster, there are some options, but it seems mired in cross browser difficulties: http://ajaxian.com/archives/how-to-make-xmlhttprequest-calls-to-another-server-in-your-domain

提交回复
热议问题