It is not as simple as it seems, and you will have to do some research on the server and on the client.
You cannot read server-side data through Javascript unless you have a connection to the server. Whatever Javascript code that runs in the client browser will remain only in the browser, even if both of them run on the same computer. You need the client (in this case, the html + javascript website) to communicate with the server.
There are endless ways to do this, but the simplest is through a GET request to the server serving this text file.
Try using static files with NGINX or perhaps something like NodeJS, depending on what suits your needs. From there, create a GET endpoint from which your Javascript will connect via XMLHttpRequest (e.g. @MattW.).
source share