You need to know two things:
1: The JSON thing is asynchronous, so the call to the sessionStatus function can already be done when the JSON is still being retrieved. The following would be done:
function sessionStatus(callback){
$(document).ready(function(){
$.getJSON(scriptRoot + "sessionStatus.php", function(status){
callback(status);
});
});
}
sessionStatus(function(s){alert(s);});
or rather:
function sessionStatus(callback){
$(document).ready(function(){
$.getJSON(scriptRoot + "sessionStatus.php", callback);
});
}
sessionStatus(function(s){alert(s);});
2: , , sessionStatus . ( JSON):
function do() {
var x = 0;
(function(){
x = 2;
})();
return x;
}
function do() {
var x = (function(){
return 2;
})();
return x;
}
2. , .