php - Watch directory for new files with javascript
I have a function called loadDATA that loads the file data.json from the server in the same directory where the js file is. I now need to watch that directory for new a new .json file that will appear every 5 minutes, grab the name and replace the initial data.json URL that is passed to the new .json filename which I will not know unfortunately.
I've been looking at js to do this but keep seeing php responses. Is it possible with js and just a pain in the ars. I'm not against using php, it's just been awhile and if I remember a little more intuitive. I did see something called node.js but it's not clear to me if it is compatible with IE as well. I open to all suggestions on approaching this. Thank you for the help.
jsonURL = "data.json";
function loadDATA() {
$.getJSON(jsonURL, function(json) {
//Do some stuff
}
Answer
Solution:
Well, I guess hypothetically you could ask for the index of the directory, and if it doesn't exist then the server should return a list of files in there, possibly even with their modification times. So that would make it possible.
On the other hand, PHP would make it so much easier.