0

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

  • 1
    Im confused about the error message. Do you wanna make a request to `http://localhost:8100` or `http://elite-schedule.net`? – Michael May 04 '15 at 10:58
  • Use Jsonp insted of json.check the below link http://stackoverflow.com/questions/6396623/jquery-getjson-access-control-allow-origin-issue – Sarath Babu Nuthimadugu May 04 '15 at 11:02
  • Since you are developing a hybrid app, you may eventually move to cordova. Take a look at whitelisting : https://cordova.apache.org/docs/en/4.0.0/guide_appdev_whitelist_index.md.html – Manish Kr. Shukla May 04 '15 at 11:28
  • but my problem that's work normal in browser and not in phone I think ,if there is an error it's not work anywhere !!! – hallo aus deutschland May 04 '15 at 12:05

1 Answers1

0

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.

Rasalom
  • 3,101
  • 3
  • 21
  • 29