我的 AngularJS 项目中的 $http 无法识别 iOS 上的 40X(401,403,405...) 错误。我正在使用 1.2.10 AngularJS 版本和 Cordova 3.4.0 版本。
下面是我正在使用的代码:
TE_SERVICES.factory('hello',function ($http,$rootScope) {
return {
loginUser: function(userCredentials,successCallback,errorCallback){
$http({
method: "GET",
url: "data/example.json",
headers: {"Authorization":'Basic '+userCredentials},
}).then(function(response){
successCallback(response.data);
console.log("Success------"+JSON.stringify(response))
},function(data, status, headers, config){
errorCallback(data);
console.log("Error------"+JSON.stringify(data)+" "+status)
})
}
}
});
hello.loginUser($rootScope.encodedUserCredencials,function(persons) {
// success handler
}, function(data) {
// error handler
console.log(data.status+"===="+status)
});
data.status
正在返回 0 并且状态返回未定义。请帮我解决这个问题。
试图将域包含在 IOS 的白名单中。但没有解决方案 :( 它仍然给出相同的响应。
但是相同的代码在 Android 中运行得非常好。请帮我解决这个问题。
提前致谢 :)