i am using ajax to submit a form in popup and i want to refresh the table after the popup is closed. 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.