How to reload a page after calling AJAX using a dialog?

so I have a dialog interface with the form when the user clicks on the link that he opens. As soon as they click the Add button, it creates an AJAX call that sends data to the database. I need to add the reload () function to refresh the page.

How to add a reboot function?

I tried adding windows.localtion.reload (); you can see my code. For some reason this line is not working

//Update contact dialog box $( "#contact-edit" ).dialog({ resizable: false, width: 500, modal: true, autoOpen: false, buttons: { "Update Info": function(e) { var formData = $('#edit-form').serialize(); //submit record $.ajax({ type: 'POST', url: 'ajax/handler-contact-update.php', data: formData, dataType: 'json', cache: false, timeout: 7000, success: function(data) { $('#response-edit').removeClass().addClass((data.error === true) ? 'errorBox' : 'passBox').html(data.msg).fadeIn('fast'); if ($('#response-edit').hasClass('passBox')) { $('#response-edit').fadeIn('fast'); $('#edit-form').hide(); $( "#contact-edit" ).dialog("close"); windows.localtion.reload(); } }, error: function(XMLHttpRequest, textStatus, errorThrown) { $('#response-edit').removeClass().addClass('errorBox') .html('<p>There was an<strong> ' + errorThrown + '</strong> error due to a<strong> ' + textStatus + '</strong> condition.</p>').fadeIn('fast'); }, complete: function(XMLHttpRequest, status) { $('form')[0].reset(); //$( this ).dialog( "close" ); } }); }, Cancel: function() { $( this ).dialog( "close" ); }, Submit: function(){ $('form')[0].submit(); } } }); 
+4
source share
2 answers

You have a typo:

 windows.localtion.reload(); 

Must be

 window.location.reload(); 
+13
source

You can try many ways to reload the page, I tried several, at least few can help someone.

 location.reload() location.reload(false) window.location = window.location window.location.reload(); 

If you use the link, use this:

 location.href = location.href 
+3
source

All Articles