Jump to content

[SOLVED] javascript die();


jaymc

Recommended Posts

I have a javascript function, which inside has 2 more functions

 

I then use another function to call the above function, works fine

 

Structure likes this

 

function 1() {
     function 2() {
                     function 3() {}
   }
}

function 4() {function 1()}

 

 

now, lets say I execute function 4, in turn I am executing function 1,2,3 simultaniously. I want to put something in function 2 and 3 where as if a condition is met it stops everything dead.

 

So, if I do something like die() in function 2, function 3 will never execute and anything else in function 4 will not be executed either

 

 

I know I can use return false and then in each of the functions check the return, but I dont want to have to pass the return down the ladder of functions and also, this wont work as I use AJAX to get content from urls, which can take 3 seconds, in which time everything else has already finished executing and the die()/return false is determined by the content from the URL

 

I really do need the javascript equivelent to php's die()

Link to comment
Share on other sites

You shouldn't just bail out of a script like that.  You're better off setting a flag somewhere in the first function that trickles down to the other functions where necessary.  It would take a millisecond to filter through the functions if the first thing you do is check that flag.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.