Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery callback function executes over and over again
    text
    copied!<p>This my jquery function,</p> <pre><code>function getRecordspage(curPage, pagSize) { // code here $(".pager").pagination(strarr[1], { callback: function() { getRecordspage(2, 5);},current_page: curPage - 1, items_per_page:'5', num_display_entries: '5', next_text: 'Next', prev_text: 'Prev', num_edge_entries: '1' }); } </code></pre> <p>and i call this jquery function,</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { getRecordspage(1, 5); }); &lt;/script&gt; </code></pre> <p>As you see my It works fine for 1st time and my <code>callback function</code> is configured to the <code>current function</code> itself... when it gets called the <code>callback</code> gets executed over and over again.... How can i prevent this? Any suggestion....</p> <p><strong>EDIT:</strong></p> <p>This is my function</p> <pre><code>function getRecordspage(curPage, pagSize) { $.ajax({ type: "POST", url: "Default.aspx/GetRecords", data: "{'currentPage':" + curPage + ",'pagesize':" + pagSize + "}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(jsonObj) { var strarr = jsonObj.d.split('##'); var jsob = jQuery.parseJSON(strarr[0]); var divs = ''; $.each(jsob.Table, function(i, employee) { divs += '&lt;div class="resultsdiv"&gt;&lt;br /&gt;&lt;span class="resultName"&gt;' + employee.Emp_Name + '&lt;/span&gt;&lt;span class="resultfields" style="padding-left:100px;"&gt;Category&amp;nbsp;:&lt;/span&gt;&amp;nbsp;&lt;span class="resultfieldvalues"&gt;' + employee.Desig_Name + '&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span id="SalaryBasis" class="resultfields"&gt;Salary Basis&amp;nbsp;:&lt;/span&gt;&amp;nbsp;&lt;span class="resultfieldvalues"&gt;' + employee.SalaryBasis + '&lt;/span&gt;&lt;span class="resultfields" style="padding-left:25px;"&gt;Salary&amp;nbsp;:&lt;/span&gt;&amp;nbsp;&lt;span class="resultfieldvalues"&gt;' + employee.FixedSalary + '&lt;/span&gt;&lt;span style="font-size:110%;font-weight:bolder;padding-left:25px;"&gt;Address&amp;nbsp;:&lt;/span&gt;&amp;nbsp;&lt;span class="resultfieldvalues"&gt;' + employee.Address + '&lt;/span&gt;&lt;/div&gt;'; }); $("#ResultsDiv").append(divs); } }); } </code></pre>
 

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