Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2008
    Posts
    93
    Thanks
    30
    Thanked 0 Times in 0 Posts

    Problems loading module

    Hello,
    I am using the following to load modules in a job aid system that we are working on:

    Code:
    var continueNow = 0;
    $.get("modules/footer.module", function(html) {alert('3');$("div#footer").append(html);});
    $.get("modules/sample.module", function(html) {alert('1'); $("div#content").append(html);alert('2');continueNow = testMe();alert(continueNow);});
    if(continueNow){alert('hi');
            /*if (addModules()){
                  if (setup()){
    		  thickbox()
    		}
    	}*/
    };
    alert(continueNow);
    function testMe(){alert('hello');
    	return(1);
    };
    When I run it, the alert just before the line function testMe() fires then the alert in the first get statement followed by the first 2 alerts in the second get statement followed by the alert in the function followed by the last alert in the second get statement. If I hard-code continueNow to be 1, the alert in the if statement is the first to fire by the rest in the same order. How can I make the if statment wait until the get's finish so I can process the information in the get's? My coworker says that this is caused by a multithreading issue.

    Thanks,
    Don
    Last edited by dragon6158; 06-20-2008 at 05:52 PM.

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    Anything you want processed after your $.get is completed should be in your callback function.


  •  

    Posting Permissions

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