我正在使用ajax在弹出窗口中提交表单,我想在弹出窗口关闭后刷新表格。我试过以下代码。
$('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;
});
但它不起作用。
答案 0 :(得分:0)
$( document ).ajaxComplete(function() {
window.opener.location.reload(false);
});
答案 1 :(得分:0)
$.post('ajax/add.php',{ajax:'get_name_list'},function(data){
objPnt.replaceWith(data);
window.location.reload();
});
答案 2 :(得分:0)
感谢所有人,我通过在以下行中替换objPnt来重新加载div类,我会回答
<div class="name">table of content</div>
$.post('ajax/add.php',{ajax:'get_name_list'},function(data){
$('.name').replaceWith(data);