0

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.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
viji
  • 313
  • 1
  • 3
  • 18

3 Answers3

0
 $( document ).ajaxComplete(function() {
  window.opener.location.reload(false);
 });
Supriya Pansare
  • 519
  • 1
  • 4
  • 11
0

have you tried this?

$.post('ajax/add.php',{ajax:'get_name_list'},function(data){
                        objPnt.replaceWith(data);
        window.location.reload();
     });
Priya jain
  • 753
  • 2
  • 5
  • 15
0

thanks for all, i use class of div to reload by replacing objPnt in following line, and i go the answer

<div class="name">table of content</div>

    $.post('ajax/add.php',{ajax:'get_name_list'},function(data){
                                $('.name').replaceWith(data);
viji
  • 313
  • 1
  • 3
  • 18