Мне нужна ваша помощь о том, как перенаправиться в другой html-файл при успешном ответе ajax в javascript.
Ниже приведен мой код, где я получаю успешный ответ ajax в jsonvariable.
Я пытался использовать window.location, но он не работает. Есть ли другой способ сделать то же самое, пожалуйста, дайте мне знать
function myFunction() {
$.ajax({
url: '/ValidateOTP',
type: 'POST',
data:JSON.stringify( $('#OTP').val()),
contentType: 'application/json;charset=UTF-8',
success: function(response){
jsonvariable=response['success'].toString();
if(jsonvariable=='true')
alert('done');
else if(jsonvariable=='false')
document.getElementById("div2").innerHTML="OTP didn't match !! Please click the GET OTP button to re-generate OTP";
document.getElementById("div2").style.color="Red";
},
error: function(response){
alert(response)
}
});
};