Prevent recursive function locking the browser <p>I have a recursive function which is locking my browser while running.</p> <p>While this function is running all my jquery commands are locked waiting for the function end.</p> <p>What should I do to make this function asynchronous? </p> <p>This function runs on document.ready</p> <pre><code>function SearchTrip() { $.post("/extensions/searchtrip", { from: $("#from").val(), to: $("#to").val(), ddate: $("#ddate").val() }, function (mReturn) { if (mReturn.fTotalAmount != '0,00') { var sAirline = ''; if (mReturn.Airline) sAirline = ' pela ' + mReturn.Airline; $("#buscandoPassagens").hide(); } else if (SearchTripAmount &lt; 5) { SearchTripAmount++; setTimeout(function () { SearchTrip(); }, 500); } else { $("#pNaoEncontrada").show(); } }, "json"); } </code></pre>