Javascript AngularJS:使用ngResource执行GET请求时的状态代码为0

Javascript AngularJS:使用ngResource执行GET请求时的状态代码为0,javascript,angularjs,Javascript,Angularjs,我对AngularJS不熟悉,所以请耐心听我说。我得到了以下代码: var testModule = angular.module("testModule", ['ngResource']); testModule.config(function($sceDelegateProvider) { $sceDelegateProvider.resourceUrlWhitelist([ 'self', 'https://api.twitter.com/**']); });

我对AngularJS不熟悉,所以请耐心听我说。我得到了以下代码:

var testModule = angular.module("testModule", ['ngResource']);

testModule.config(function($sceDelegateProvider) {
    $sceDelegateProvider.resourceUrlWhitelist([
    'self',
    'https://api.twitter.com/**']);
}); 

testModule.controller("SecondController",
    function SecondController($scope, $resource){
        $scope.secondField = "Hello World";
        try{
            var restClient = 
                //$resource("https://api.github.com/repos/angular/angular.js/issues", [],
                $resource("https://api.twitter.com/1.1/search/tweets.json", [],
                    {
                        "get":{method:"GET", headers:{"Accept":"application/json"},
                            interceptor: {
                                "response":function(data){
                                    alert("Response: " + data);
                                },
                                "responseError":function(data){
                                    alert("Error: " + data);
                                }
                            }
                        }
                    });
            $scope.about = restClient.get();
        } catch(err) {
            $scope.error = err.message;
        }
        $scope.done = true;
    }
);
它应该执行responseError函数,data.status应该等于215(请求需要身份验证才能成功通过)。相反,响应代码为0

实际上,我正在尝试访问另一个API(不需要身份验证),但状态代码也是0,我真的不知道会出现什么问题。到目前为止,我唯一能成功执行的请求是:

得到

由$resource.query()执行。但twitter和目标API都无法实现。我希望为twitter示例提供一个解决方案可以帮助我解决问题

谢谢


编辑:使用AngularJS 1.2.0 rc2这可能是因为跨域请求。当您尝试访问不同域的web服务时,将出现状态代码0。在这种情况下,您需要在ngResource中使用JSONP作为方法

http://docs.angularjs.org/api/ngResource.$resource