I've got a function that initiates an AJAX call function to get some information. after that it returns an object. Is it possible to delay the return call until after the AJAX data has been processed?
here's the code for it, basically I'm trying the alert for 'obj' to come before the alert for 'gotten'
Code:function buildUpdate(x,y) { var updateDiv = $(document.createElement('div')).addClass('contentPage').attr('id','updateWindow'); var section = $(document.createElement('section')).attr('id','aboutSection').css({ width: (x - 16) + 'px', height: (y - 16) + 'px', margin: '8px', }).appendTo(updateDiv); getXML(); alert('gotten'); //////////// return updateDiv; } function entry(title,date,time,message) { this.title = title; this.date = date; this.time = time; this.message = message; alert('obj'); //////////// updateArray.push(this); } function readUpdates(result) { var entries = $(result).find('entry'); $.each(entries,function(index) { var title = $(this).find('title').text(); var date = $(this).find('date').text(); var time = $(this).find('time').text(); var message = $(this).find('message').text(); var _entry = new entry(title,date,time,message); }); } function getXML() { $.ajax({ type: "GET", url: "updates.xml", dataType: "xml", success: readXML }); }


Reply With Quote
Bookmarks