Kory
Kory

Reputation: 21

How to load a txt file to use as a list of data for variables in Ajax & Jquery?

This is my first time here on stackoverflow and I wanted to ask if anyone knew a way to load a txt file that contained the string of all the variables I wanted to use in my variable for my website. I think if show you the code it will be easier to see what I'm talking about.

var sc2List = "wcs_america,esltv_sc2,Nathanias,TeSLLive,Sc2tv_ru,destiny,Painuser,dreamhacksc2,idrajit,demuslim,eghuk,redbullesports,EmpireTvZERG,desRowfighting,ProTech";

So this is my variable that is used by this function:

$(".wow").click(function(){
    getStreamList(wowList);
});

My question is, is there a way to store wcs_america, esltv_sc2 etc into a txt file so its easier for me to store and update versus hard coding it into my index file? Thank you so much for all responses!

Upvotes: 1

Views: 136

Answers (1)

Brigand
Brigand

Reputation: 86270

You can use AJAX to files from the server.

$.get("myvariables.txt", function(data){
    alert("My variables are " + data);
});

Upvotes: 1

Related Questions