Browser message after AJAX request

3

I have an ajax request responsible for sending a file to the servlet, it is performing the process correctly. But when I update the page the following message is displayed by the browser (When I give an f5):

  

The page you are looking for has used inserted information. To return to this page you can have all actions taken be re-ordered. Do you want to continue?

I do not want this message to appear for my users.

Ajax request:

$(document).ready(function($) {
    $("#formAv").submit(function(event) {
        var dados = new FormData(this);
        var url = "Avatar";
        $.ajax({
            url: url,
            type: 'GET',
            data: dados,
            mimeType: "multipart/form-data",
            contentType: false,
            cache: false,
            processData: false,
        });
    });
});

The message is from the browser itself, I tried to clean the form after sending but it did not solve.

    
asked by anonymous 21.04.2016 / 17:33

1 answer

2

This warning that the browser gives only happens when you submit a form via the HTML API. That is, using <form action="" . Once you are using ajax, you should cancel the submission of the form via HTML API and submit, as you are doing via ajax.

To cancel the natural action you can do with event.preventDefault() . In that case your code could look like this:

$(document).ready(function($) {
    $("#formAv").submit(function(event) {
        event.preventDefault();
        var dados = new FormData(this);
        var url = "Avatar";
    
21.04.2016 / 18:12