Sorry, I can’t seem to find a good reference to this anywhere on the Web, other than very complex versions or examples that do something far more complex than I need…
I’m just trying to figure out how to read from a simple txt file (that resides on the server with the other HTML files), that is read in (via Javascript) and displayed on the page (…for example, a daily news section). I’ve done this easily in Flash, years ago, but I’m a little puzzled by the correct, current way of doing it in HTML with Javascript.
I have seen things as simple as news = “c:\News\news.txt”… but, that’s for a local file, and I’m not sure that would work with a relative online URL (…if that even works at all!).
I’ve seen it done via loadStrings, which looked promising… but I couldn’t get that to work. (It’s not vanilla Javascript, but requires P5.js)
I imagine (once it’s in) I’d utilize innerHTML to actually place it in a spot, specified by ID.
Ideally, I could inject the text as actual HTML, rather than pure text, so that I could have tags on various parts of the external text, to allow CSS styling to be targetted to those different parts… although, I wouldn’t complain if it just comes in as pure text to be displayed literally (as a text block).
Just looking for very simple 'plog this text from an external file into this < div > or < p >… Any help?
UPDATE: I’m currently trying to do it with JQuery, but am having no luck there, so far, either…
UPDATE2: Okay, this is odd… I got it to work with JQuery (using .load)… but it only appears to work in Pinegrow’s preview, and not in my external browser (Firefox). Normally, I’d think I have some security-based blocking happening… but I’m not sure if that’s the case.