hi all i’ve got this bit of code but it keeps kicking out ‘undefined;
var projectID = $.getUrlVar('id');
var projectname;
$.get('functions.php?func=projectname&id='+projectID, function(data) {
projectname = data;
alert(projectname+'<- see nice content');
});
alert(projectname+'<- no content :(');
how can i make “projectname” available outside that one get function?
(i did notice, when running that code actually, that the no content alert popped up before the nice content. is the .get the last thing on the page that runs? is this why its all blank? coz the variable doesnt appear to be set yet?
thanks
AJAX runs asynchronously (that is what first
AinAJAXacronym stands for).So you have 2 solutions for your issue:
$.getto$.ajaxand set itsasyncoption to false (terrible solution)