简体   繁体   中英

Angularjs - Calling json web service always returns 404

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);

          });

      };
 }

使用Chrome或FireFox Developer Tools并打开“网络”选项卡,然后试一下,看看实际发生的情况是什么,这将有助于您发现问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM