Refresh Current Page after sweetalert Ok Popup

sweet alert redirect after ok
sweetalert loading
sweet alert for loading dialog
javascript alert library
how to reload a page after the ok click on the alert page

I want to refresh current page after Sweet Alert

Below is the javascript code in my C# code enter code here

  url = HttpContext.Current.Request.Url.AbsoluteUri;
  ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", "alert('Please enter the correct data');window.location='" + url + "';", true); 


 url = HttpContext.Current.Request.Url.AbsoluteUri;
 ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", "swal('success','Please enter the correct data','success');window.location='" + url + "';", true); 

Page is getting refresh but sweet alert is getting missed Please suggest Thanks in Advance

Issue solved on Ok button click Jquery was implemented at the client side

   $(document).ready(function () {
        $(".swal-button").click(function () {
            window.location = 'Profile.aspx';

How can execute location.reload after I clicked the okay button , Closed. filjoseph1989 opened this issue on Mar 29, 2016 · 2 comments. Closed url: the_url, success: This case the sweetalert will exit and then the location.​reload will execute, I would like to click the okay first the execute location.reload. fabianchoxD changed the title gl when i click ok button of sweet alert.. send to another page Nov 12, 2014 Copy link Quote reply varunsridharan commented Nov 12, 2014

There is a major difference between alert() and swal() which you seem to be missing:

function foo(){    

When the alert pops up, unless you acknowledge the message, the next statement does not get executed.

function foo(){    

the log statement gets executed irrespective of the acknowledgement of the user.

So the appropriate snippet for you would be:

swal('success','Please enter the correct data','success').then((value) => {

Though for some older versions you might have to do it this way

  title: "Good job!",
  text: "You clicked the button!",
  icon: "success"
}, function(value){

You can find the documentation here at:

Using SweetAlert and location.reload(), I want to show a sweet alert message when a user clicks on this ajax post preventDefault(); var url = '{!! url() ! before it does the reload so how can I display this message via sweet alert for 3 its the same.. just implement it in javascript.. instead of sessions use localstorage Ok will do, i'm on it now. A custom positioned dialog. position: 'top-end', icon: 'success', title: 'Your work has been saved', showConfirmButton: false, Custom animation with Animate.css. title: 'Custom animation with Animate.css', popup: 'animated fadeInDown faster' popup: 'animated fadeOutUp faster' A confirm dialog, with a function attached to the "Confirm"-button

Try this one. It may help you out.

 url = HttpContext.Current.Request.Url.AbsoluteUri;
 ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", "swal('success','Please enter the correct data','success');window.location.href='" + url + "';", true); 

Make jQuery reload the page after second popup Solutions, I'm using SweetAlert on a project and it works great but I'm trying to modify What I want is to reload the page after the user clicks on the "OK"  Sweet Alert 2 scrolling to top of page after firing with magnific popup ajax #781

Page refresh after pop-up, I am trying to set a page to refresh after adding some data to it's underlying database. Active Threads · Unanswered Threads · Unresolved Threads you can directly refresh parent window from javascript of pop up window. If you wish to refresh the page only after the user clicks 'OK' button on alert box  Closes the currently open SweetAlert, as if you pressed the cancel button. swal.close() getState: Get the state of the current SweetAlert modal. swal.getState() setActionValue: Change the promised value of one of the modal's buttons. You can either pass in just a string (by default it changes the value of the confirm button), or an object.

Creating Pretty Popup Messages Using SweetAlert2, Once you have installed the library, creating a sweet alert is actually very easy. All you When a single argument is passed and it is a string, the sweet alert will only show a title and an OK button. If you happen to use the same set of properties for multiple alert messages during their Update me weekly. As the title suggests, the problem occurs (in this case), when I press the "OK" button, just after the opening of the popup. If pressed immediately after the opening of the popup, the callback function is not called.

SweetAlert2, A confirm dialog, with a function attached to the "Confirm"-button. '​Deleted!', 'Your file has been deleted.', 'success' ) } }) and by passing a parameter, background: '#fff url(/images/trees.png)', if (!response.ok) { undefined, Current active progress step. Swal.update({ options }), Updates popup options. @t4t5 Hey thanks for SweetAlert :) I found the solution for this issue and sharing it below. I know its old but i found the solution so i hope it helps anyone. @mp3il @azlannohara @masteradhoc The problem is the shorthand in the closure.

  • after adding this snippet into my scriptmanager alert is coming but disappering immediately swal('success','Please enter the correct data','success').then((value) => { window.location=url })
  • Can you please provide more details as to what you are trying to achieve? The above snippet successfully redirects to the provided URL when the success button is clicked.
  • there is profile page where some information is manditory where i am updating data after the refresh due to which refresh is important for me please suggest some thing which would refresh as well as shows pop
  • So after refresh of the page, the pop up must still be present?
  • Ya that should be happen but it is getting disapper