I'm simply trying to read a one line .txt
file to a variable. I later want to show that variable in the webpage.
My folder structure:
NewsAlerts
index.html
assets
searchterms.txt
js
newsalerts.js [THIS is the .js that runs the code below]
css
style.css
My searchterms.txt
is solely comprised of:
Chicago AND Illinois OR (Summer AND Winter)
so I am simply expecting my javascript variable to hold that string.
Code:
var search_terms = $(".text").load("assets/searchterms.txt");
$("#terms_submission").on("click", function(){
$("#terms_list").add("<span>" + search_terms);
alert(search_terms.valueOf());
});
jQuery does seem to be loading something, if I add alert(search_terms)
, I get [object Object]
. But doing search_terms.text()
returns ""
so maybe it's correctly creating an Object variable ...but with nothing in it.