Read text file and put result to innerHTML?

I want to use JavaScript to change the text of an element with Id ‘foo’.
The text it should change to should be taken from a file titled ‘bar.txt’ (can also be any other file format, as long as I get a string from the text inside.)

The text file and the HTML containing the script are in the same directory, and are visible to the client.

Searching for my problem on Google only led me to this link, which is for uploading a file to the website and isn’t what I need.