AngularJS在成功获取请求后抛出错误

2024-04-20 10:08:50 发布

您现在位置:Python中文网/ 问答频道 /正文

通过这段代码,我试图从服务器获取数据

$scope.get_file_list = function() {
            delete $http.defaults.headers.common['X-Requested-With']; //We don't wat OPTIONS but GET request
            $http({method: 'GET', url: backendUrl + '/session/' + $scope.id + '/list'})
                .success(function(data, status, headers, config) {
                    // ...
                })
                .error(function(data, status, headers, config) { console.log(
                    'error\ndata: '+data+
                    '\nstatus: '+status); });

服务器:

^{pr2}$

这里是浏览器的控制台输出

[18:58:37.409] "error
data: 
status: 0

服务器用代码200响应,当我用浏览器测试它时,一切正常(服务器发送数据时没有在控制台发出任何警告)。 也许我应该用jQuery来做这个?在


Tags: 代码服务器confighttpdatagetstatus浏览器