Mike Mike - 3 months ago 9
jQuery Question

How do I reload the page after an AJAX call is done with a dialog?

so I have a dialog UI with a form once a user click on a link it opens. Once they click "Add button" it create a AJAX call that submits the data into the database. What I need to add is reload() function to refresh the page.

How can I add the reload function?

I have tried to add windows.localtion.reload(); you can see it my code. That line does not work for some reason

//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
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')) {
$( "#contact-edit" ).dialog("close");
error: function(XMLHttpRequest, textStatus, errorThrown) {

.html('<p>There was an<strong> ' + errorThrown +
'</strong> error due to a<strong> ' + textStatus +
'</strong> condition.</p>').fadeIn('fast');
complete: function(XMLHttpRequest, status) {
//$( this ).dialog( "close" );


Cancel: function() {
$( this ).dialog( "close" );
Submit: function(){


You have a typo:


Should be