Immediately after sending a request to the server, the ajax function terminates without waiting for a response.
How to make the success method come after receiving a response from the server? As far as I understand it, async: should be true so that the createInProgress method continues to work and the user can see the progress line.
.js
$(document).ready(function () { var options = { success: function (responce) { //сюда заходит alert("Success"); }, error: function () { $('div#in_progress').remove(); }, }; $("#getSityData").ajaxForm(options); }); function executeOperation() { var url = "/getSityData", city = "Berlin"; createInProgress('progressboxSityData'); $.ajax({ type: 'POST', url: url, data: {city: city}, async: true, dataType: 'json', success: function (response) { //сюда не заходит $('div#in_progress').remove(); } }); }
timeoutas a parameter "how much to do nothing while a request is being made" - Alexey Shimansky