且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

跨域 $http 请求 AngularJS

更新时间:2022-05-12 06:26:48

api.nestoria.co.uk 似乎不允许 CORS.它必须自己设置 Access-Control-Allow-Origin 标头 - 您无法直接控制它.

It seems that api.nestoria.co.uk does not allow CORS. It has to set the Access-Control-Allow-Origin header itself -- you have no direct control over that.

但是,您可以使用 JSONP.该站点通过 callback 查询参数允许它.

However, you can use JSONP. That site allows it via the callback query parameter.

$http.jsonp(baseurl+'country=uk&pretty=1&action=search_listings&place_name=london'
    +encoding+type + "&callback=JSON_CALLBACK")