How to implement reverse ajax in php mysql to get DB updates

612 Views Asked by At

I want to get updates from db on a particular time interval or at the time of DB changes. and that will affect on the client web pages insistently

1

There are 1 best solutions below

0
On

you need something like this

 function checkUpdate()
        {
            $.ajax({
                url: "/explorer/checkUpdate",// Ajax url to get update
                dataType:'json',
                type:'post',
               data:'',//data required to fetch update from db
                success:function(msg){
                    if(msg.status)
                    {   
                        // end update
                    }
                    else
                    {

                        //write code to update html element or add data to list.
                        setTimeout(checkAndDownload, 3000);
                    }
                }
            });

This will continuesly ping server after certain interval so that if any update you can get it.