AngularJS $ http.jsonp请求失败

时间:2014-05-10 08:43:45

标签: javascript ajax json angularjs

我已经向需要身份验证的大型json文件写了一个ajax调用。

 var responsePromise = $http.jsonp("http://url_to_file/file.json", 
                                      {headers: {'Authorization': 'Basic ' + btoa(username + ":" + password)}});

 responsePromise.success(function(data, status, headers, config) {
        alert("Success")
 });
 responsePromise.error(function(data, status, headers, config) {
        alert("AJAX failed!");
 });

当检查chrome developer工具中的Network选项卡时,我可以看到请求成功,状态为200,但promise objec仍然在错误回调中被cactched:

enter image description here

我做错了什么?

0 个答案:

没有答案