I have a page with several user controls that use Ajax. When I try to do window.location from this page, Ajax traps the call and does not allow the redirect.
$.ajax({
url: 'assets/php/action.php',
method: 'post',
data: $("#register-form").serialize()+'&action=register',
success:function(response){
$("#register-btn").val('Sign Up');
// console.log(response);
if(response === 'register'){
alert("you will now be redirected");
window.location = 'home.php';
}
else{
$("#regAlert").html(response);
}
}
});
Use this rather window.location.href = 'home.php';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.