When the following jquery ajax function is called:
let ajax_call = function (endpoint, request_parameters) {
$.getJSON(endpoint, request_parameters)
.done(response => {
if(response['success']){
setTimeout(function(){
$('div#validation_result').html('<span class="validate_answer" style="color:green;"><i class="fas fa-check fa-2x"></i><span>');
}, 150);
else{
setTimeout(function(){
$('div#validation_result').html('<span class="validate_answer" style="color:red;"><i class="fas fa-times fa-2x"></i><span>');
}, 150);
}
}
}
Using the browser debugger, I am going line by line and to my great surprise, the response success settimeout executes AND the else settimeout executes after that. I cannot believe my eyes, but this is actually happening. Any ideas what could cause this?