I searched a lot before doing this post, however I could not solve my problem. When I submit a form through synchronous requests ($ .POST), I have no problems. From the moment I submit through asynchronous requests, ie - $ .ajax, I notice that my form returns with the old data - until I refresh the page.
Example: Consider that an input is recorded with the value "Home". When you replace with "Apartment" and submit the form, it writes correctly, however, returns with the value "Home" in the field. When reloading the page, then it displays the value correctly.
$("#formulario").submit(function() {
var varform = $('.serialize').serialize();
$.ajax(
{
type: "POST",
url: "../envia-cadastrar-contrato2",
data: varform,
datatype : 'html',
success: function(resposta)
{
... BLA BLA BLA
} else { }
}
});
});
I've already made some code changes, including preventDefult in form, but it did not work. Could you help me with this?