jaymc Posted June 17, 2008 Share Posted June 17, 2008 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() Quote Link to comment Share on other sites More sharing options...
ober Posted June 17, 2008 Share Posted June 17, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.