I am building a photo sharing service in php. I am using a lightbox in jquery which will popup when we click 'add' button to add photos. We can upload multiple photos. Also I am using ajax to upload photos so that the page is not reloaded. I want that after I upload photos the same will be automatically loaded in my gallery and the gallery should display new photos without need to refresh the page. The photos will have a particular id for a particular user in the database, so ulitmately the change in the table for the user should be reflected. Now the problem is that I don't have control over the closing button of the lightbox. Therefore I cannot modify it to call any other function so that it performs the query and displays my photos using ajax. I have heard that we can detect changes in the database automatically using JSON, but I have never used JSON and know almost nothing of it. Can anyone illustrate a simple example in php of how can the changes in a mysql table detected using JSON? Is there any other way to achieve it? Please help me.
JSON an ideal data-interchange language.JSON is used for fast data interaction only.so you can not do this with out help of DOM request. http://www.json.org/
You can do this with ajax. You make ajax request for every second for latest update.
or
use long polling method like comet
Implement COMET with PHP
EDIT:- gowri:How to make ajax request per second?
use setInterval
setInterval(function(){
//make your ajax call here
},1000);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With