https://i.sstatic.net/RvqYQ.pngMy code seems to have an issue with the if/else
statement. I am checking the value of data.success
which should contain either true
or false
. However, when I use (data.success === true)
in the if statement, the else block executes and vice versa. Can anyone spot the mistake in my code?
$scope.verifyMobile = function () {
var otp = {
"otp": $scope.mobile.otp
};
$http({
method: 'POST',
url: 'verify_mobile',
data: otp,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).success(function (data, status, headers, config) {
if (data.success) {
$scope.verified = true;
$scope.sms_sent = false;
} else {
alert(data.message);
}
}).error(function (data, status, headers, config) {
});
};