I have a folder where xml files are uploaded including livescore data for matches. I want every time an xml arrives, a php parser to be triggered, parse the data and refresh an html page on a browser displaying the livescore data. I can make the folder monitoring and php triggering but I am concerned on how to make the page refresh without the client request.
I have a folder where xml files are uploaded including livescore data for matches.
Share
This can be accomplished using AJAX. If you’re unfamiliar with the method, it involves using JavaScript to fetch data without refreshing the website.
Your problem could be solved by making an AJAX script that every few seconds requested new content from the webserver, e.g. using a call like /newdata.php?date=1321640052. The server then checks if there has been new data since 1321640052 (a UNIX timestamp of the last content refresh – or when the page was first loaded). If there has been, the page contains a value (yes) to indicate new data is available, and JavaScript refreshes the page. Alternatively, you could just dynamically update the content using AJAX after the call has been made.