not sure @ why doesn't work.
var jimmy = $.get("info.txt"); jimmy = jimmy.split("\n"); why have this:
$.get("info.txt", function(jimmy) { jimmy = jimmy.split("\n"); }); the second way works fine, make things easier if first way, , i'm not sure why can't done. it's different php.
check out in developer tools:
var jimmy = $.get("info.txt"); console.log(jimmy); you see jimmy have javascript info(callbacks) on $.get doing , response be. lot more information want, want response data. thing first option second line executed before response back, because $.get asynchronous.
that why second option working. when info.txt loaded execute inside of function(callback). information can read.
to make global this.
var sjors = ''; $.get("info.txt", function(jimmy) { sjors = jimmy.split("\n"); }); a global variable created when outside function. sjors global variable content of jimmy.
Comments
Post a Comment