Note that there are some explanatory texts on larger screens.

plurals
  1. POSorting generated rows tablesorter
    primarykey
    data
    text
    <p>Currently I have a script that gets information from the database after typing (500ms). The first time when I give in a parameter it's completely working but the second time if I give an other parameter it doesn't do things right. When I click the headers of the table it add like 15 rows, however I first delete them and my limit on my query is 5 rows.</p> <p>How to fix this ?</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script&gt; jQuery(document).ajaxStop(function() { jQuery("#myTable").tablesorter(); }); var delay = (function() { var timer = 0; return function(callback, ms) { clearTimeout(timer); timer = setTimeout(callback, ms); }; })(); $(document).on("keypress", "#searchValue", function() { delay(function() { $("#myTable tbody").empty(); var name = $("#searchValue").val(); $.post("&lt;?php echo site_url('project/searchProject'); ?&gt;", { name: name }, function(data, status) { var items = ""; data = $.parseJSON(data); if (data.toString() !== "") { $.each(data, function(index, item) { items += "&lt;tr&gt;" + "&lt;td&gt;" + item.Code + "&lt;/td&gt;"; items += "&lt;td&gt;" + item.Description + "&lt;/td&gt;"; items += "&lt;td&gt;" + item.ProjectLeader + "&lt;/td&gt;"; items += "&lt;td&gt;" + item.AccountManager + "&lt;/td&gt;"; items += "&lt;/tr&gt;"; }); } $("#myTable tbody").append(items); }); }, 500); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input type='text' name='searchValue' id='searchValue'/&gt; &lt;br&gt; &lt;br&gt; &lt;table id='myTable' class='tablesorter'&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Code&lt;/th&gt; &lt;th&gt;Description&lt;/th&gt; &lt;th&gt;Project leader&lt;/th&gt; &lt;th&gt;Account manager&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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