I know this is something really fundamental, but I am not quiet getting it. I am trying to define a variable abc
as global variable and then printing it out at the end. But it returns undefined
. Printing it inside works just fine.
var abc;
var data;
$.get('http://localhost:3000/test.php', function (data, status) {
console.log(status);
abc = data;
console.log(abc); //printing it here works fine
});
console.log(abc); //printing it here returns undefined