cross-domain AJAX post call

后端 未结 2 1079
生来不讨喜
生来不讨喜 2021-02-06 13:35

I\'ve to make a POST call(with parameter) to an asp form which is located on another server.

For development, I did this on the same server, and it works perfectly, but

相关标签:
2条回答
  • 2021-02-06 13:54

    Yes, assuming you can change the server you connect to

    You can implement Cross Origin Resource Sharing (CORS)

    You need the server to return Access-Control-Allow-Origin: * if you want to allow all domains to access, otherwise return Access-Control-Allow-Origin: http://yourdomain.com

    If you cannot change the server you are accessing, you need to use a proxy on the server your script comes from - alternatively investigate if they have published an API to return for example JSONP

    More details here

    • MDN HTTP access control (how)
    • W3Org (Implemation details)
    • MSDN XDR

    and several links to the right of this questions

    0 讨论(0)
  • 2021-02-06 14:07

    You can either create a proxy script, or use jsonp. The easier course would be to use a proxy script on your server.

    0 讨论(0)
提交回复
热议问题