Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery AJAX loop to refresh jQueryUI ProgressBar
    primarykey
    data
    text
    <p>I've got a jQueryUI progressbar that should show the percentage of a query done. Oracle has a nice system table that lets you see operations that will take more than 10 seconds. I'm trying to make staggered $.ajax calls to this query in order to refresh the progress bar.</p> <p>Problem is, I can either get the loops to make rapid-fire requests without any wait time, or just delay the entire JavaScript from executing.</p> <p>I start the first request by clicking my "Execute" button in a jQueryUI dialog.</p> <pre><code>$("#dlgQuery").dialog({ buttons: { Execute: function () { $(this).dialog("close"); StartLoop(); } } }); </code></pre> <p>I'm trying to build either the <code>StartLoop()</code> function or make a recursive <code>GetProgress()</code> function. Ideally, I will have a public variable <code>var isDone = false</code> to act as my indicator for when to terminate the loop or stop recursively calling the function.</p> <p>For simplicity I have just made a static loop that executes 100 times:</p> <pre><code>function StartLoop(){ for (var i = 0; i &lt; 100; i++) { GetProgress(); } } </code></pre> <p>And here's my sample ajax request:</p> <pre><code>function GetProgress() { $.ajax({ url: "query.aspx/GetProgress", success: function (msg) { var data = $.parseJSON(msg.d); $("#pbrQuery").progressbar("value", data.value); //recursive? //GetProgress(); //if (data.value == 100) isDone = true; } }); } </code></pre> <p>So what I've found is, so far:</p> <p><code>setTimeout(GetProgress(), 3000)</code> in <code>StartLoop()</code> freezes Javascript, and the dialog does not close (I assume, because it will wait until the query is done).</p> <p><a href="http://www.sean.co.uk/a/webdesign/javascriptdelay.shtm">This</a> one, <code>pausecomp(3000)</code> does much the same thing.</p> <p>If I call either of these in the "success" function of my AJAX request, it gets ignored (probably because it's starting another call asynchronously).</p> <p>I'm kinda stuck here, any help would be appreciated, thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload