Can not grasp, why then do interval. But not the essence. Response to mine just after clearInterval to take and make another request, though the same $.ajax.
Example:
var interval; function show(url) { $.ajax({ type: "POST", url: url, data: "username=" + $("#username").val(), dataType:"json", success: function(data) { if (data.result == "error") { console.log(data); setTimeout(function() { clearInterval(interval); // another request $.ajax({ type: "POST", url: "someurl", dataType:"json", success: function(data) { // some actions } }); }, 1000*30/2); } else { console.log(data); } } }); return false; }
It would be better if it has anything to divide and decorate than cabecou noodles continue to climb.
Because of the range can be a problem - a timeout need to ask once, and clear in case of success. In General, there are many "but".