Loading cross-domain endpoint with AJAX

前端 未结 9 1692
醉酒成梦
醉酒成梦 2020-11-21 05:20

I\'m trying to load a cross-domain HTML page using AJAX but unless the dataType is \"jsonp\" I can\'t get a response. However using jsonp the browser is expecting a script m

9条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-21 05:45

    You need CORS proxy which proxies your request from your browser to requested service with appropriate CORS headers. List of such services are in code snippet below. You can also run provided code snippet to see ping to such services from your location.

    $('li').each(function() {
      var self = this;
      ping($(this).text()).then(function(delta) {
        console.log($(self).text(), delta, ' ms');
      });
    });
    
    
    
    • https://crossorigin.me/
    • https://cors-anywhere.herokuapp.com/
    • http://cors.io/
    • https://cors.5apps.com/?uri=
    • http://whateverorigin.org/get?url=
    • https://anyorigin.com/get?url=
    • http://corsproxy.nodester.com/?src=
    • https://jsonp.afeld.me/?url=
    • http://benalman.com/code/projects/php-simple-proxy/ba-simple-proxy.php?url=

提交回复
热议问题