When sending a request via AYAX, the script infinitely shows a loader.

I send request with such code.

$.ajax({ type: "POST", url: 'components/my/core.php', data: formNm.serialize(), success: function (data) { // Вывод текста результата отправки $(idusersendmessage).html(data); $("#content_"+formID).css('display', 'block'); $('#loader_' + formID).html(""); }, error: function (jqXHR, text, error) { // Вывод текста ошибки отправки $(idusersendmessage).html(data); $("#content_"+formID).css('display', 'block'); } }); 

In the core.php file itself there is an API call to another site. These requests are many, it happens that it takes 5 minutes to process. API requests themselves are executed here, but the Ajax returns nothing, and the loader is turned. Tell me how to solve this problem?

    1 answer 1

    Five minutes? Some kind of rot in the Danish kingdom.

    http://api.jquery.com/jquery.ajax/

     $.ajax({ type: "POST", url: 'components/my/core.php', data: formNm.serialize(), timeout: 0, success: function (data) { // Вывод текста результата отправки $(idusersendmessage).html(data); $("#content_"+formID).css('display', 'block'); }, error: function (jqXHR, text, error) { // Вывод текста ошибки отправки //$(idusersendmessage).html(data); $("#content_"+formID).css('display', 'block'); }, complete: function(jqXHR, textStatus) { $('#loader_' + formID).html(""); } });