This is not the first time I am working with ajax and such, I want to use the jQuery function $.getJSON
I have written the following:
var newIMG;
function random_img(){
$.getJSON('content/random.php',function (data){
newIMG = data;
})
alert(newIMG.ERROR);
}
But for some reason I can't access the newIMG variable after the JSON request has been made. Passing it from the $.getJSON function to the random_img() function in some way would be fine as well (better, actually)
It's really strange and I can't figure out what's the problem here.
https://i.sstatic.net/OShao.jpg Screenshot of the firebug console, may explain it better.
Thanks in advance guys.
;after the})