Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reload a page after clicked ok using sweetalert

Hello I have a code using sweetalert

swal("Good job!", "You clicked the button!", "success")

this code will pop-up a message and has a button okay, what I like to do is I want to refresh the page after I click the okay button.

Can I do that?

like image 958
Fil Avatar asked Mar 30 '16 06:03

Fil


3 Answers

Use the callback function...

Swal.fire({
  // Swal Setting's
}).then((result) => {
  // Reload the Page
  location.reload();
});
like image 124
Jan Heil Avatar answered Sep 17 '22 05:09

Jan Heil


You can try this, it works for me.

swal({
       title: "Good job", 
       text: "You clicked the button!", 
       type: "success"
     },
   function(){ 
       location.reload();
   }
);
like image 31
Yoshioka Avatar answered Oct 19 '22 09:10

Yoshioka


The answer from Yoshioka did not work for me, I did this and it worked perfectly:

swal({title: "Good job", text: "You clicked the button!", type: 
"success"}).then(function(){ 
   location.reload();
   }
);
like image 28
Leo C Avatar answered Oct 19 '22 09:10

Leo C