Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would give the same answer as this <a href="https://stackoverflow.com/questions/4427740/jquery-json-populate-table/4427870#4427870">jquery json populate table</a></p> <p>This code will give you a little idea how to use callback with loops and ajax. But I have not tested it and there will be bugs. I derived the following from my old code:-</p> <pre><code>var processCnt; //Global variable - check if this is needed function formSubmit(){ var lines = $('#urls').val().split('\n'); $.each(lines, function(key, value) { $('#dlTable tr:last').after('&lt;tr&gt;&lt;td&gt;'+value+'&lt;/td&gt;&lt;td&gt;Not Started&lt;/td&gt;&lt;/tr&gt;'); }); completeProcessing(lines ,function(success) { $.ajax({ url: 'process.php?id='+value, success: function(msg) { $('#dlTable').find("tr").eq(key+1).children().last().replaceWith("&lt;td&gt;completed rip&lt;/td&gt;"); } }); }); } //Following two functions added by me function completeProcessing(lines,callback) { processCnt= 0; processingTimer = setInterval(function() { singleProcessing(lines[processCnt],function(completeProcessingSuccess){ if(completeProcessingSuccess){ clearInterval(processingTimer); callback(true); }})}, 1000); } function singleProcessing(line,callback) { key=processCnt; val = line; if(processCnt &lt; totalFiles) { //Files to be processed $.ajax({ url: 'status.php', success: function(data) { $('#dlTable').find("tr").eq(key+1).children().last().replaceWith("&lt;td&gt;"+data+"&lt;/td&gt;"); processCnt++; callback(false); } }); } else { callback(true); } } </code></pre>
    singulars
    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.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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