I have a big problém, I made a small application ionic , angularjs that works without error, when I add $http.get()
call to receive a JSON file the browser displays the error:
我有一个很大的问题,我做了一个小应用程序离子,angularjs工作没有错误,当我添加$ http.get()调用接收一个JSON文件浏览器显示错误:
XMLHttpRequest cannot load ..... No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access.
$http.get("http://elite-schedule.net/api/leaguedata")
.success(function(data) {
deferred.resolve(data);
}) .error(function() {
console.log("Error while making HTTP call.");
deferred.reject();
});
I add the extension Allow-Control-Allow-Origin: *
and the application returns run but my problem in my phone (android) it does not display anything I think we should allow this appeal $http.get
我添加了扩展名Allow-Control-Allow-Origin:*并且应用程序返回运行但我的手机中的问题(android)它没有显示任何我想我们应该允许这个上诉$ http.get
please, who knows display console.log () in the phone , to know the source of the error or who has already this error
请知道谁知道手机中的console.log(),知道错误的来源或谁已经出现此错误
thank you a lot
非常感谢
1 个解决方案
#1
This kind of question occurs every day. Firstly read about CORS: https://ru.wikipedia.org/wiki/Cross-origin_resource_sharing
这种问题每天都在发生。首先阅读CORS:https://ru.wikipedia.org/wiki/Cross-origin_resource_sharing
Then if you can change server configuration, then do it(if it's ok for your security policy, of course). If not, do jsonp request. If it's not available either.. find another API.
然后,如果您可以更改服务器配置,那么就这样做(当然,如果它适用于您的安全策略)。如果没有,请执行jsonp请求。如果它不可用..找到另一个API。
#1
This kind of question occurs every day. Firstly read about CORS: https://ru.wikipedia.org/wiki/Cross-origin_resource_sharing
这种问题每天都在发生。首先阅读CORS:https://ru.wikipedia.org/wiki/Cross-origin_resource_sharing
Then if you can change server configuration, then do it(if it's ok for your security policy, of course). If not, do jsonp request. If it's not available either.. find another API.
然后,如果您可以更改服务器配置,那么就这样做(当然,如果它适用于您的安全策略)。如果没有,请执行jsonp请求。如果它不可用..找到另一个API。