Hi $http.get works successfully when run on w3Schools editor. (http://www.w3schools.com/angular/tryit.asp?filename=try_ng_http_get)
The same code fails when run on my local server. Here is the code and response in either case. code: <!DOCTYPE html> <html> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <body> <div ng-app="myApp" ng-controller="myCtrl"> <h1>successful response: {{data}}</h1> <h1>error: {{error}}</h1> </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope, $http) { $http.get("http://www.w3schools.com/angular/welcome.htm") .then(function(response) { $scope.data = response; }, function(reason){ $scope.error = reason; }); }); </script> </body> </html> when run in w3schools editor, the successcallback is executed and $scope.data is {"data":"Hello AngularJS Students", "Status":200, "config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"url":"http://www.w3schools.com/angular/welcome.htm","headers":{"Accept":"application/json, text/plain, */*"}}, "statusText":"OK"} when run on my local server, $scope.error is {"data":null,"status":-1,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"url":"http://www.w3schools.com/angular/welcome.htm","headers":{"Accept":"application/json, text/plain, */*"}},"statusText":""} -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
