Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
DataTable Refresh with Two Methods

I have two trigger function that used for two functions. end point is once the objective is completed DataTable would be reloading. as per this case, One function is working when the other is not. The not working one's process is a simple add function with a modal popup. once it is added it will be displayed on the datatable real-time. below is the function.

    //DOESN'T REFRESH TABLE

    $(document).on('click','#add',function(event){
        event.preventDefault();
        $('#add-cat').html('');
        var id = $(this).data('id');
        $.ajax({
            type:'POST',
            url:'../cat/modal/add.php',
            data:{id:id},
            success : function(data)
            {
                $('#add-cat').html(data);

                //TO REFRESH TABLE
                $('#example').DataTable().ajax.reload();
            }
        });
    });

The refreshing one real-time as per requirement is below

     //REFRESHES TABLE
     $(document).on('click','#con',function(event){
        if(confirm("Are you sure?")){
            event.preventDefault();
            var id = $(this).attr('data-id');
            $.ajax({
                url     : '../ord/stat.php',
                method  : 'POST',
                data    : {id : id},
                success : function(data)
                {
                    $('#example').DataTable().ajax.reload();
                }
            });
        }
        else{
            return false;
        }
    });

Why the first one is not updating the table and the second one is?

Regards.

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!