user3472548
user3472548

Reputation: 77

$http.get() in angular js always returns with error and status code 0

I am making a call to a REST webservice,which is returning error all the time ,However when I observed in fiddler its returning the status with 200 and always showing the JSON what I am expecting.

var app=angular.module("register",['ui.bootstrap']);
app.controller("RegistrationController",function($scope,$http){
 $scope.submit=function()
{
    $http.get("http://localhost/blog/blogindex.php?firstname=venu&lastname=gopal")
        .success(function(data)
        {
            alert('Success');
        }).error(function(status,data){
            alert(data);
        });
};

});

Any idea what is going wrong here.When I debugged with developer tools of the browser,its always returning to error where as the fiddler displays the status 200 and JSON correctly

Upvotes: 1

Views: 3942

Answers (1)

user1563700
user1563700

Reputation:

It could be a problem with the same origin policy:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS

this can help to solve it: http://enable-cors.org/

Upvotes: 2

Related Questions