Results 1 to 2 of 2

Thread: Possible to delay function from reaching end of code

  1. #1
    Join Date
    Apr 2010
    Brooklyn NY

    Possible to delay function from reaching end of code

    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'

    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',
    	alert('gotten');            ////////////
    	return updateDiv;
    function entry(title,date,time,message) {
    	this.title = title;
    	this.date = date;
    	this.time = time;
    	this.message = message;
    	alert('obj');            ////////////
    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() {
    		type: "GET",
    		url: "updates.xml",
    		dataType: "xml",
    		success: readXML

  2. #2
    Join Date
    Feb 2003
    Michigan, USA
    Add "asyn: false" to the options you pass into $.ajax. This will make the browser UI freeze until the AJAX call has been completed. It really sounds like you need a way to notify outside code that the node has been filled. I take it you want to do something after the DIV has been filled?

    Can you post all the JavaScript you are trying to use, minus jQuery? It's difficult to solve this problem without seeing more code.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center