Javascript pause problem in a loop, ajax, jquery -


I am trying to create a simple animation. Short story short, I've got a list of 20 small divisions and one out-of-the-box. I want to display five small devices within a bigger div at that time. Ideally, I will get a 5 second set of 5 divisions.
I am using jquery ajax function to create small divs, here is the code:

  $ (document) .ready (function () {var amount = 0; $ Ajax ({Type: "GET", url: "SampleServiceIncidentList.xml", Datatype: "XML", Success: Function (xml) {// Creates divs inside GadgetMain div, works fine.}); Zodiac = $ ("# GadgetMain") (children's volume: "+ zodiac"); // This displays in a test area divideFeed ();} // close success}}; // Close $ .jx (function divide () divides the set of small divisions in {// groups} var limit = 5; var pagesNo = Math.ceil ((zodiac / boundary)) var min = 0; var max; var I = 0; while (i & lt; pagesNo) {minimum = i * limit; maximum = minimum + range; // // problem here // populate (minimum, maximum); i ++;}} function populate (minimum , Max $ {"(# # GadgetMain div)" AddClass ('hidden'); // hides all small divs $ ("# testText"). + Min + 'max:' + max); // divs current group Print (0-5; 5-10 etc.) $ ("#GadgetMine Diva"). Piece (minimum, maximum) .removeClass ('hidden');}  

});

So, the problem is that I can not get it to w AIT is interested in displaying a set of dividends in 5 seconds. I know that it divides the divs correctly - when I alert the minimum and maximum value, it changes the contents of each partition when I close the alert. But I can not find a way to stop the function.

I would be very grateful for some help, I'm running madness

You do not want to stop the function; Instead, you want to take control back to the browser and call it back after an interval. The function does this (also related, but I usually like setTimeout .)

There is some mental logic inversion, but it is like calling a very ajax - You ask something

For example:

  function doSomething (x) {runner ()); Function Runner () {console.log ("x =" + x); --x; If (X> 0) {window.setTimeout (Runner, 1000); }}} DoSomething (10);  

... less than 10, once per second. doSomething returns almost immediately, but then runner is called back once again until it rearranges itself.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -