In this code, OTPVerficationHTML() function having condition that data.rval == 2, where it should redirect to signin page and display the message in that page only
var flag = 0;
$("#successPrimary").on('click', function(e) {
e.preventDefault()
user_name = $('#Login_UserName').val();
password = $('#Login_Password').val();
captcha = $('#Login_captcha').val();
var PostData = {};
PostData['put'] = true;
PostData['form_login_username'] = user_name;
PostData['form_login_password'] = password;
PostData['form_login_captcha'] = captcha;
Application.Post("/ajax/ajax_login", PostData, function(data){
if(data.rval == 1){
window.location = "/offerletter/index";
Application.PageAlertBox.Show('Sucess', ['Login Successfully.']);
}else if(data.rval == 2){
OTPVerficationHTML()
Application.PageAlertBox.Show('info', ['Enter OTP to Verify.']);
}else{
Application.PageAlertBox.Show('error',[data.Message]);
}
});
});
var OTPVerficationHTML = function () {
initial_html = $('#otpfromlogin').html();
$('#otpfromlogin').empty();
$('#buttons').empty();
$('#otpfromlogin').append(final_html);
$('#Login_UserName').val(user_name);
$('#Login_UserName').attr('readonly', 'true');
$('#Login_UserName').focus();
}
$('#otpfromlogin').on('click', '#otp-verify', function(e) {
e.preventDefault()
otp = $('#form_otp').val();
var PostData = {};
PostData['put'] = true;
PostData['form_login_otp'] = otp;
Application.Post("/ajax/ajax_loginwithotp", PostData, function(data) {
if(data.rval == 1) {
window.location = "/offerletter/index";
Application.PageAlertBox.Show('Sucess', ['Successfully Loggedin.']);
} else if(data.rval == 2) {
window.location = "/signin";
Application.PageAlertBox.Show('info', ['OTP is Expired, Pleasem login with new OTP.']);
} else if(data.rval == -4) {
Application.PageAlertBox.Show('error', ['OTP is Invalid. Please Enter correct OTP.']);
} else {
Application.PageAlertBox.Show('error', [data.Message]);
}
});
});
It is not displaying the message on signin page. I don't know how to deal with this kind of situation.