Bill N Bill N - 1 year ago 95
Ajax Question

How to automatically execute a JavaScript function after a .txt file has updated

Python code periodically updates the string data in a variable then using, write & close() saves the data as a txt. When the txt has been saved AJAX.load needs to be able to recognize that an update has occurred then automatically execute a function. Is there a way to monitor the Python generated txt file for a change? Or monitor its date/time stamp for a change? that could be used to signal that the change has occurred then execute the JavaScript function?

Answer Source

If you're using node.js you can use, but I doubt it can be used from the browser.

If you're using the browser, you should probably fall back to either polling (if you can afford additional traffic) or watcher on the server side (e.g. with watch) + notification to client (e.g. via

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download