Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery problem with (a)synchronous method calls
    text
    copied!<p>I have an strange behavior, which looks lika an problem with (a)synchronous method calls?!? I'm not sure! An function receives data using getJSON, post process those data, add them to an table, which is sortable by the table-sorter plugin (http://tablesorter.com/). </p> <p>Here some parts of the code. A function receives data by getJSON:</p> <pre><code>jQuery.getJSON(url,{},function(data) { success:{ .... </code></pre> <p>in the success block, the data will be processed in an for-each loop. during that for-each loop, every JSON element will be manipulated (doSomething()) an added to an HTML table:</p> <pre><code>success:{ [some-code] $.each (data.words, function (i,n) {result=doSomething(n); obj=jQuery('#Template').clone().appendTo('#table'); obj.html(result); } </code></pre> <p>finaly, after that for-each i have to update the Table-sorter -extension and start an new sorting:</p> <pre><code> jQuery("#table").trigger("update"); $("#table").trigger("sorton",[[[1,1]]]); }; //end of "success </code></pre> <p>This code is simplified. The Problem is, that <code>$("#table").trigger("sorton",[[[1,1]]]);</code> only works correctly, if i start this function delayed <code>setTimeout('$("#trends").trigger("sorton",[[[1,1]]]);',20);</code>.</p> <p>I think, that the output <code>obj.html(result);</code> will be asynchronous. So if i start the sorter-function without <code>setTimeout</code>, the sorter-function founds no data at runtime.</p> <p>Is there a way to make that success block linear?</p> <p>Thank you, for any kind of help!!</p>
 

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