'How can I read from a local txt file and check when it changes in javascript?

I want to make my js program read from a txt file whose location is hardcoded. Every time the txt file is update, I want to store the new data as a new variable. For example, when the txt file changes from blank to the following:

Lorem ipsum dolor sit amet

it will store newInfo = "Lorem ipsum dolor sit amet" Then if the txt file is updated to the following:

Lorem ipsum dolor sit amet
consectetur adipiscing elit

It will store newInfo = "consectetur adipiscing elit"



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source