使用对话框完成AJAX调用后,如何重新加载页面? [英] How do I reload the page after an AJAX call is done with a dialog?
本文介绍了使用对话框完成AJAX调用后,如何重新加载页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,一旦用户单击打开的链接,我就会获得一个带有表单的对话框UI.一旦他们单击添加按钮",它将创建一个AJAX调用,将数据提交到数据库中.我需要添加的是reload()函数来刷新页面.
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?
我试图添加windows.localtion.reload();你可以看到我的代码.该行由于某种原因无法正常工作
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
$.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();
}
}
});
推荐答案
您有错字:
windows.localtion.reload();
应该是
window.location.reload();
这篇关于使用对话框完成AJAX调用后,如何重新加载页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文