I have a scrolling text in JavaScript that has some variables in it.
I get the variables through a PHP script and then print them on the scrolling text.
The problem is (I think) that the script doesn't have the time to get the variables before the page finishes loading so I get my variables become = 'undefined'.
But if after the phpscript but before populating the scroller I call an alert();
, after I click 'ok' the scroller is populated with the right information on the variables.
How can I make the code wait for the variables to be populated and then load the page?
Code:
var test;
$.ajax({ url: 'getSlaTCO.php', success: function (data) { test = data } });
var memorycontent = test;
function populatescroller() {(...)}
The way it gets correctly populated:
var test;
$.ajax({ url: 'getSlaTCO.php', success: function (data) { test = data } });
alert('hey there!');
var memorycontent = test;
function populatescroller() {(...)}