Overcoming Cross-Domain issues

前端 未结 3 1487
日久生厌
日久生厌 2021-01-25 13:03

Are there any ways to overcome the cross domain issues that occur when attempting to retrieve data client-side from another web server in violation of the Same Origin policy?

相关标签:
3条回答
  • 2021-01-25 13:35

    Instead of referencing a third party domain directly from the client, call up to your hosting domain and have the server retrieve whatever you're getting from the third party domain.

    0 讨论(0)
  • 2021-01-25 13:47

    http://en.wikipedia.org/wiki/JSONP

    http://api.jquery.com/jQuery.getJSON/#jsonp

    0 讨论(0)
  • 2021-01-25 13:47

    I concur with Greg D, it is easy enough to make an AJAX call to a script on your domain that uses curl to fetch a resource from another domain. Just remember that you will most likely want to cache the fetched file on your server so you don't have to go get it every single time a page is viewed.

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