In our web application there are data tables. Those data tables are updating automatically through ajax requests. So we are sending ajax requests each 5 seconds to server. As a result so many requests and so much bandwidth is wasted. I want to know whether there is a option that update data tables there is only change in database. When new record is added to database, automatically generate a request and update client web page. My current code is as follows. Our server side language is php and database is mysql.
<script>
    var dtable= $('#ajax_load_table').DataTable( {
        "ajax": '<?php echo base_url(); ?>dashboard/jobs_approved_json_refresh',
        columns: [
            { data: "job_code" },
            { data: "cus_name" },
            { data: "priority" },            
            { data: "department" },
            { data: {
                _:    "last_action.display",
                sort: "last_action.s_order"
            } },
            { data: "status" },
            { data: "action","width": "30%" }
        ],
        "order": []
    } );
 window.setInterval(function () {
    dtable.ajax.reload();
 }, 5000);
</script>
 
     
     
     
     
    