Anyone know the best way to achieve this?
The window.setTimeout(function(){ } ,3000); doesn't help....
Hi all,
Need a bit of advise/help
I want to show a sweet alert message when a user clicks on this ajax post request to notify the user that they are now following the other user. Here's what I have already.
<script>
$(document).ready(function(){
$('#followUser').click(function(e) {
e.preventDefault();
var url = '{!! url() !!}/follow/{!! $profile->user->id !!}';
$.ajax({
type: "POST",
url: url,
data: {
'follower': '{!! Auth::id() !!}',
'followed_by': '{!! $profile->user->id !!}'
},
cache: false,
success: function(){
swal({
title: "Success!",
text: "You are now following",
type: "success",
timer: 3000,
showConfirmButton: false
});
window.setTimeout(function(){ } ,3000);
location.reload();
}
});
return false;
});
});
</script>
But the sweet alert only display in a matter of milliseconds before it does the reload so how can I display this message via sweet alert for 3 seconds then just has the alert disappears, do the reload??
So i decided to do it like this and seems to be working now, thanks for the help and advise.
localStorage.setItem("swal",
swal({
title: "Success!",
text: "Message sent",
type: "success",
timer: 3000,
showConfirmButton: false
})
);
location.reload();
localStorage.getItem("swal");
Please or to participate in this conversation.