Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax call to complete success, before actually completing the call?
    text
    copied!<p>I'm trying to figure out an ajax call... I need the call to hold up and finish loading HTML contents, before going over once again (it is triggered by keyup event)... Otherwise returned HTML is actually loaded multiple times. In my case the ajax call returns HTML which then executes a JS function. But when it gets loaded multiple times, JS function is executed twice = bad.</p> <p>Here is my code (alert boxes are only for help...):</p> <pre><code>$(document).ready(function() { var isProcessing = false; $('#productSearchInput').keyup(function() { var productSearchInput = $(this).val(); var dataString = 'searchInput='+ productSearchInput; var script_url = '../ajax/service-search.php'; if(productSearchInput.length &gt; 3 &amp;&amp; isProcessing === false) { $.ajax({ type: 'GET', url: script_url, data: dataString, beforeSend: function() { isProcessing = true; alert('Processing input: ' + productSearchInput; }, success: function(server_response) { $('#searchresultdata').html(server_response).show('fast', function() { alert('Currently processing...'); } ); }, error: function() { alert('ajax call failed...'); }, complete: function() { isProcessing = false; alert('Processing done'); } }); } return false; }); }); </code></pre> <p>What is wrong is, that the "Processing done" alert appears before the "Wait for processing" alert... And then after "Processing done" alert has showed, the "Wait for processing" alert shows.</p> <p>I need my HTML server_response to show, before completing the call and setting isProcessing = false;...</p> <p>How do I achieve that?</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