CrazyMac
CrazyMac

Reputation: 462

Angular $http calls not working in Chrome or Firefox

I have a simple Angular $http.get and post calls. It works perfectly in IE but not in Chrome or Firefox.

I kept a break point in the JS and debugged, it just breaks exactly in the line of $http.get('urlAPI') and don't see any guidance for this. The debug takes me to the details of angular methods which I was not able to follow..

Anyone have faced a similar issue or any guidance here. I am using Angular version 1.5.8.

Here is my simple Angular code

$scope.wakeup = function() {
    $http.get('getTimings').then(function() {
    }
}

Upvotes: 0

Views: 915

Answers (1)

Cruzer
Cruzer

Reputation: 143

Please Use this following: If your server side scripting is PHP then it will work: (if ASP.NET you should add web service to GET in web.config file)

IMP: Please make sure you have used ng-app and ng-controller name exactly as used in html

 <p>Today's welcome message is:</p>

 <h1>{{myWelcome}}</h1>

</div>

 <p>The $http service requests a page on the server, and the response is set as the value of the "myWelcome" variable.</p>

 <script type="text/javascript">
 var app = angular.module('myApp', []);
 app.controller('myCtrl', function($scope, $http) {
 $http.get("welcome.php") // you can use welcome.htm also
 .then(function(response) {
 $scope.myWelcome = response.data;
    }, function(error){
        console.log(error)
    });
 });
</script>

Upvotes: 1

Related Questions