AngularJS:$ HTTP.GET是越来越取消 [英] AngularJS: $HTTP.GET is getting cancelled

查看:139
本文介绍了AngularJS:$ HTTP.GET是越来越取消的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用angularJS的$ http服务,但它似乎并没有工作。我已经在网上阅读约占这样一个问题,但考虑到解决方案并不能帮助。我已经在我的控制器以下内容:

I am trying to use $http service of angularJS but it doesn't seem to work. I have read up online about such an issue but the solutions given doesn't help. I have the following in my controller:

app.controller('Ctrl', function($scope, $http){    
    var url = http://someurl?name=foo;
    $scope.submitRules = function(){
        $http({method: 'GET', url: url}).
              success(function(data, status) {
                $scope.status = status;
                $scope.data = data;
              }).
              error(function(data, status) {
                $scope.data = data || "Request failed";
                $scope.status = status;
              });
    };
});

我使用这个版本angularJS的&LT;脚本src=\"https://ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular.min.js\"></script>

每当我尝试发送它表明请求状态的取消的请求。 ,我发送请求的URL是很好的工作,它只是不工作形式angularJS。
有人可以帮忙吗?

Whenever I try sending the request it shows that the request status is cancelled. The URL that I am sending the request to is very well working it just doesn't work form angularJS. Can someone help?

推荐答案

如果这不是CORS,您可以检查使用铬与CORS扩展,尝试设置您的请求超时:

If it's not CORS, which you can check using chromium with CORS extension, try to set timeout of your request:

app.controller('Ctrl', function($scope, $http){    
    var url = http://someurl?name=foo;
    $scope.submitRules = function(){
        $http({
            method: 'GET',
            url: url,
            timeout: 50000
        }).
        success(function(data, status) {
          $scope.status = status;
          $scope.data = data;
        }).
        error(function(data, status) {
          $scope.data = data || "Request failed";
          $scope.status = status;
        });
    };
});

设置$ httpProvider的从不工作对我来说,这是相当服务器问题。

Setting $httpProvider never worked for me, it's rather server matter.

这篇关于AngularJS:$ HTTP.GET是越来越取消的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆