1

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

5
  • 1
    I noticed a callback, any chance it is jsonp? Commented Apr 19, 2014 at 13:45
  • @MarkColeman Hi Mark,I have developed a PHP service and hosted in my local machine and when I browse this URL in my browser I am getting JSON response and I am using XAMPP for this webservice Hosting.Is there any setting which is denying the request or the angular is having some issue to invoke $http.get Commented Apr 20, 2014 at 4:38
  • Is there any more info in your browserlog? Commented Apr 21, 2014 at 12:44
  • No,There is no info in the browserlog. Commented Apr 23, 2014 at 11:49
  • Hi,I checked my browser log and it says this error message XMLHttpRequest cannot load localhost/blog/blogindex.php?firstname=venu&lastname=gopal. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost:63342' is therefore not allowed access Commented Apr 25, 2014 at 2:10

1 Answer 1

2

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/

Sign up to request clarification or add additional context in comments.

4 Comments

Hi,THanks for your reply,But this doesn`t help me.
Can anybody help me in solving this?
I hope this is the problem,what should I do to resolve this?I added in my php file as header("Content-Type:application/json;Access-Control-Allow-Origin: *"); Still that did not work for me
I got this resolved by adding header("Access-Control-Allow-Origin: *"); in a separate line in php file

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.