0

I am new to angularjs. I am using it with ionic framework. I am trying to calling a json web service but it always returns 404.

When I try in browser it works perfectly fine.

here is my code:

function FetchCtrl($scope, $http) {

    $scope.fetch = function() {

        $http({method: 'GET', url: 'http://example.com/anyservice'}).
          success(function(data, status, headers, config) {

            alert("data "+data);
          }).
          error(function(data, status, headers, config) {

            alert("error "+status);

          });

      };
 }
3
  • Try the get request on example.com/anyservice with a browser http request to see if the service really responds Commented Jun 24, 2014 at 7:52
  • Is the API on a different domain than the angular app is loaded from? In that case it could be a CORS problem. Commented Jun 24, 2014 at 7:53
  • I checked in Rest Console, the service is responding properly. Commented Jun 24, 2014 at 8:03

1 Answer 1

1

Use either Chrome or FireFox Developer Tools and open the Network tab, then give it a shot and see what the actual request is that is happening, that should help you finding your problem.

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

1 Comment

Hey I checked it again on Chrome Developer Tool and came to point that my server was not allowing access of the service from other server. so I created a service and placed it to my server. Now I am getting the response properly. Thanks for you help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.