I’m currently working on creating a website that needs to access the text stored in a text file and parse it into a data structure. I would like to use a javascript function or an html tag to include or call the file so that I can parse it. However, I can’t seem to find a good way to do it. Any suggestions?
I’m not sure how to be more specific, but perhaps some pseudocode might help. Current code would be along these lines:
mylist = new Array();
function myfunc()
{
var str = [get information from website];
mylist.push(str);
}
That is, if the website has the following text:
"<tag attr=str attr=str>text</tag>"
The newest (or last) element of mylist would be "<tag attr=str attr=str>text</tag>".
Thanks!
edit: Thanks for the quick responses. I was trying to steer away from jquery (actually, I’m implementing angular in the site), but I was trying to use a native javascript method as opposed to a library. Judging from the responses, there isn’t one. Thanks for your help!
You should use the XHR Object, aka the “AJAX” method.
Here’s an overview as to how to start using it.
Here’s an excerpt: