简体   繁体   中英

angular.js $http.post not working in phone

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:

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

please, who knows display console.log () in the phone , to know the source of the error or who has already this error

thank you a lot

This kind of question occurs every day. Firstly read about 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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