Is it possible to start execution of a queue in the middle of another execution?
Hello everyone,
- <html>
- <head>
- <script type="text/javascript" charset="utf-8" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
- <script type="text/javascript">
- $(document).ready(function()
- {
- var status = "run";
- var temp = 1;
- while(status == "run")
- {
- (function(temp, status)
- {
- $("body").queue("exprQueue", function(next)
- {
- temp++;
- if(temp == 1000)
- {
- status = "stop";
- $('div').html(temp);
- }
- next();
- });
- })(temp, status);
- $("body").dequeue( "exprQueue" );
- }
- });
- </script>
- </head>
- <body>
- <div></div>
- </body>
- </html>
when the document is ready, a while loop will be executed every time checking the status variable. Inside this loop, a queue method is scheduled which will change the status variable. When i run this piece of code, the browser freezes and i guess the queue method is not executed before completion of while loop.
Could anyone help me solve this problem?
Thank you in advance