i'm aware of $digest already in progress error issue, but here i'am not calling the apply or digest method explicitly
I'm using two http calls in same angularJS function which leads me to the Error that $digest already in progress, My code is like
$http.post('/CRUDOper/memberInsert',$scope.memberAdd).
success(function(post){
if(!post.IsSuccess){
alert(post.msg + "Try Again");
return;
}
alert("Member Added Successfully");
}
);
var autopass = Math.random().toString(36).slice(-8);
var passwordinsert = {formno : $scope.memberAdd.formno, password : autopass };
$http.post('/CRUDOper/autogeneratepassword',passwordinsert).
success(function(post){
if(!post.IsSuccess){
alert(post.msg + "Try Again");
return;
}
alert("Autogenerated Password for present user : " + autopass );
}
);
both the request are called correctly what my concern is the error in the firebug that $digest already in progress is there any way i can handle this error ?
AngularJS' event loop does not wait until alert()
, confirm()
, and prompt()
return a value (at least for $http
calls). There is, however, a short interval between rendering the popup and entering into the $digest
loop. This explains why OP did not get the error the first time: OP clicked or pressed return very soon.
To verify for yourself that this does not depend on the number of http calls, try using one alert in the success()
method of a single http call. There will be no error if you confirm the popup within approx. 300ms, but there will be an error if you confirm it at a later time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With