Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9015765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:49:56+00:00 2026-06-16T03:49:56+00:00

how can i pause a javascript execution until a flag becomes true? For Example,

  • 0

how can i pause a javascript execution until a flag becomes true?

For Example, i’ve a xml message like this:

[...]
<action>
    <resource update>id</resourceupdate>
</action>
<action>
    <event>id1</event>
</action>
<action>
    <event>id2</event>
</action>
<action>
    <event>id3</event>
</action>
[...]

I wish that the event nodes are processed only after processing node resourceupdate (which requires more time to be served, as it requires the loading of a page):

in javascript to process this message with an iterator (each) i’ve tried:

$(_response).find('ACTION').each(function() {       
if (tagName=="RESOURCEUPDATE") {
    ready = false;
    //load the resource with selected id in an iframe
} else if (tagName=="EVENT") {
    browserLoaded();   //the waiting function
    eventhandler();  //consume the event
}
});

the waiting function is:

function browserLoaded() {
if (!ready) {
    setTimeout(browserLoaded(),1000);
}
} 

and the ready var becomes true when the iframe is loaded:

$(iframe).load(function() {
    ready = true;
});

but when execute i’ll catch this error:

 Maximum call stack size exceeded error

any ideas?
thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:49:57+00:00Added an answer on June 16, 2026 at 3:49 am

    It’s really a bad idea to use some kind of a flag. You have to use Deferred Pattern. Something like this:

    var resources = [];
    $(_response).find('ACTION').each(function() {
      var deferred = resources.length > 0 ? resources[resources.length - 1] : null;
    
      switch (tagName) {
        case "RESOURCEUPDATE":
          deferred = $.Deferred();
    
          //load the resource with selected id in an iframe
          $(iframe).bind('load', function () {
            deferred.resolve(/*specific arg1, arg2, arg3, ...*/)
          });
          resources.push(deferred);
          break;
        case "EVENT":       
          if (deferred) {
             deferred.done(function (/*specific arg1, arg2, arg3, ...*/) {
                // process event node
             });
          }
          break;
      }
    });
    
    // clean up deferreds objects when all them will be processed
    $.when.apply($, resources).then(function() {
      resources.length = 0;
    })
    

    P.S.: http://api.jquery.com/category/deferred-object/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to pause execution of javascript until after the DOM changes are completed.
I want to pause execution in javascript so that I can animate the appearance
I have this javascript: triggerAnimation(listItem,toggleToggleRadioListItem(listItem)); function triggerAnimation(listItem,passThruFunction){ listItem.find(.inlineLoading).show(); // pause and then call the
Using Javascript/jQuery, how can I pause (or resume) the following loop when the P
I'm looking for a good approach to sometimes pause an action (function/method call) until
Given my animation scene1 . How can I pause it using a button named
I have a class which represents exam,it can start/reset/pause exam, so the methods look
I want to pause the timer thread....or i can say want to put it
Can anyone please help me to add video controls (play, pause, forward, seekbar) to
Let's say I want to pause a thread so that other threads can run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.