I want to display a message as "loading" while processing the registration and another with "Registration complete", this is my AJAX code
$.ajax({
type: "POST",
url: "http://localhost:5001/v1/enterprise",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify(data),
crossDomain: true,
success: function(data) {
guid = data;
$(".cad_sucesso").css({
display: 'block'
})
setTimeout(function() {
$(".cad_sucesso").fadeOut();
$(".processo_sucesso").css({
display: 'block'
})
setTimeout(function() {
window.location.href = "/dataImmobile/DataImmobile/NewImmobile";
}, 1000);
}, 3000);
},
failure: function(data) {
alert(data.responseText);
},
error: function(data) {
alert(data.responseText);
}
});
What am I doing here? By first displaying a div with a 'loading' message, and after a few seconds it displays the div with the 'cadastro complete' message, but it is not dynamic since I am setting the time to display the messages. How do I take the time for this requisition?