Is it correct to do one post request inside another? And if not - is it possible to somehow send 2 responses from the server to the client at once? I now have this code:

$.post("auth.php", {'login': login, 'password': pass, 'remember': remember}, function(data){ if(data == "false"){ grecaptcha.reset(); var div = document.querySelector("#div"); div.innerHTML = "Неправильный логин или пароль"; }else if(data == "true"){ $.post("auth.php", {"idl": login}, function(data){ alert(data); window.location.href = "profile.html?"+data; } ); } }); 

Can replace it with a get request?

    1 answer 1

    You have not 2 requests in one, but 2 requests coming one after the other. In principle, this is normal.

    The function that comes with the third argument in $.post is executed after the request has been completed.