【发布时间】:2015-11-17 01:04:29
【问题描述】:
我正在使用一些向服务器端发送 $http 异步请求的函数。如果响应为“notlogin”,我想在重新登录用户后调用相同的当前函数。我想我需要使用 Promise,但是如何使用?
$scope.A = function(){
$http({..,async: "isAsync",...})
.success(function (response) {
if (response.d == "notlogin") {
if ($scope.B())//call back login to refresh session
$scope.A();//repeat request if login return true
}
});
};
$scope.B= function () {
$scope.userlogin_error = "wait...";
$http({...,async: "isAsync",...}).success(function (response) {
if (response.d == "True") {
$scope.userlogin_error = "login success";
$scope.user_islogin = true;
return true;
}
});
}
【问题讨论】:
-
什么是函数
B? -
是登录功能...
标签: jquery angularjs xmlhttprequest async-await angular-http