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




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.

People are also looking for solutions to the problem: php - Split a string by comma, quote and full-stop.. with a few exceptions


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.