[英]refresh a page after ajax form submit
i am using ajax to submit a form in popup and i want to refresh the table after the popup is closed. 我正在使用ajax在弹出窗口中提交表单,并且我想在弹出窗口关闭后刷新表格。 i have tried this below code.
我试过下面的代码。
$('body').delegate('#add','click',function(){
var objPnt = $(this).parents('form');
name=objPnt.find("#name").val();
error='';
if(name === '')
{
error="<div class='alert alert-info'><span class='icon icon-color icon-alert'/>Name field is required</div>";
}
$.post("ajax/add.php", $("form.addform").serialize(),function(html){
if(html === 'incorrect'){
objPnt.find("#add_err").css('display', 'inline', 'important');
objPnt.find("#add_err").html(error);
}
else
{
objPnt.find("#add_err").css('display', 'inline', 'important');
objPnt.find("#add_err").html("<div class='alert alert-info'><span class='icon icon-color icon-check'/>Name Added Successfully.</div>");
}
});
$.post('ajax/add.php',{ajax:'get_name_list'},function(data){
objPnt.replaceWith(data);
});
return false;
});
but it doesn't work. 但这不起作用。
$( document ).ajaxComplete(function() {
window.opener.location.reload(false);
});
have you tried this? 你尝试过这个吗?
$.post('ajax/add.php',{ajax:'get_name_list'},function(data){
objPnt.replaceWith(data);
window.location.reload();
});
thanks for all, i use class of div to reload by replacing objPnt in following line, and i go the answer 谢谢大家,我使用div类通过替换下一行中的objPnt来重新加载,然后我就回答了
<div class="name">table of content</div>
$.post('ajax/add.php',{ajax:'get_name_list'},function(data){
$('.name').replaceWith(data);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.