This question has already been answered:
Good day! For example, given the function
function Test(){ var req = $ajax(...); req.done({function(responce){ console.log(responce); }); return ... }; In this case, the function will return something without waiting for the request to be executed and return readyState: 4; Actually the question is as follows. How to wait for readyState 4 before continuing after ajax?
donefunction (if everything is fine) is completed and everything that needs to be done after the completion of the request can be done in it. - Grundy