简体   繁体   English

跨域JSON请求未返回数据。 (AngularJS)

[英]Cross-domain JSON request not returning data. (AngularJS)

I've been trying all day to get the JSON data from the following url: https://www.easports.com/iframe/fifa17proclubs/api/platforms/XBOXONE/clubs/2650219/membersComplete 我整天都在尝试从以下网址获取JSON数据: https : //www.easports.com/iframe/fifa17proclubs/api/platforms/XBOXONE/clubs/2650219/membersComplete

I am very new to cross-domain calls, I tried to use JSONP, $get.JSON with no success. 我对跨域调用非常陌生,我尝试使用JSONP,$ get.JSON失败。 All I want is to store the data from that link into an Angular variable so I can use it on my app. 我想要的只是将来自该链接的数据存储到Angular变量中,以便可以在我的应用程序中使用它。

This is a browser security restriction (cross site script attack) and requires the server to add the following response in the header in order for your browser-based app to access the data 这是浏览器的安全限制(跨站点脚本攻击),并且要求服务器在标头中添加以下响应,以使基于浏览器的应用访问数据

Access-Control-Allow-Origin: *

If you cannot get the server to change, then there's nothing you are going to be able to do. 如果您无法更改服务器,那么您将无能为力。 This restriction does not exist if you create a desktop app - it's just a browser security restriction. 如果您创建桌面应用程序,则不存在此限制-仅仅是浏览器安全限制。

More information here: 此处有更多信息:

https://enable-cors.org/server.html https://enable-cors.org/server.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM