How to constantly update data when records change in the database, on web networks or during long polling

I use datatables as my grid in webapp. The problem is that the user must constantly refresh the page in order to receive current data from the database, is there a way to do this automatically? because several applications write to the same table, and webapp - only for monitoring, but this beats the goal if the user needs to refresh the page to get the current data. here is my initialization code:

  $('.{{datatable['class']}}').dataTable( {
                "sDom": 'T<"clear">lfrtip',
                "oTableTools": {
                    "sSwfPath": "includes/swf/copy_csv_xls_pdf.swf",                
                    "aButtons": [
                         { 
                             "sExtends":"copy",
                             "mColumns":[{{datatable['flds']}}]
                         },
                         {   
                             "sExtends":"csv",
                             "mColumns":[{{datatable['flds']}}]
                         },

                         {
                             "sExtends":"xls",
                             "mColumns":[{{datatable['flds']}}]
                         },                         
                         {
                            "sExtends": "pdf",
                            "mColumns":[{{datatable['flds']}}],
                            "sPdfOrientation": "landscape",
                            "sPdfMessage": "{{datatable['title']}}"
                         }
                    ]
                    },        
                "bProcessing": true,
                "bServerSide": true,
                "sAjaxSource": "{{datatable['source']}}",
                "aoColumns": [          
                        {% for column in 0..datatable['columns']-2 %}
                        null,
                        {% endfor %}
                        null
                ]

        });

Is there a way in which the list can be updated every time something (UPDATE / INSERT / DELETE) happens to the data source? I implemented the cycle suggested by Danny,

var int=self.setInterval(function(){oTable.fnDraw();},1000);

but the problem is that the list is always a ridiculous state, see the attached image enter image description here

+5
1

ajax, , , , . , , , , //, - , , , , .. / javascript var .

+2

All Articles