Add if else function in Ajax Jquery function
Posted
by
Naga Botak
on Stack Overflow
See other posts from Stack Overflow
or by Naga Botak
Published on 2012-10-12T03:34:58Z
Indexed on
2012/10/12
3:36 UTC
Read the original article
Hit count: 170
Is it possible to add other else function in my JS like this: ?
if response == success redirect to home
if response == failed redirect to failed
$.ajax({
type: "POST",
url: action,
data: form_data,
success: function(response)
{
if(response == 'success')
window.location.replace("home");
else
$("#message").html("<div class='error_log'><p class='error'>Invalid username and/or password.</p></div>");
}
});
© Stack Overflow or respective owner