Reputation: 25
Please help me i need to reload page after successful member login.
This is my code but nothing changes (page doesn't reload).
Note: I am using Laravel 5.4
$.ajax({
url: 'json/login',
type: "POST",
data : {
'email' : $("#connection :input[name='email']").val(),
'pwd' : $("#connection :input[name='pwd']").val(),
'_token' : $('meta[name="_token"]').attr('content')
},
dataType : "json",
success: function(data,statusText,xhr){
if(data.success == 'ok'){
$(document).ajaxStop(function() { location.reload(true); });
}else{
$("#alert_danger").html(data.message);
$("#alert_danger").slideDown(100).delay(2000).slideUp(100);
$("#alert_success").slideUp(100);
}
}
});
return false;
});
Upvotes: 0
Views: 211
Reputation: 1025
I think you should just do this :-
if(data.success == 'ok'){
location.reload(true);
}
Using $(document).ajaxStop does not make sense since you are already in the success function.
Upvotes: 1