1
I have a requisition problem
when I click save button it makes 1 request or be saved 1 time in the bank if click again it does 2 at once saving 2 times in the bank clicking again it does 3 at a time saving 3 times in the database.
need to have 1 per click.
follows code
html
<form id="form" class="" action="javascript:;" enctype="multipart/form-data" name="form" method="post">
<button class="btn btn-primary" name="" onclick="sub('achadoPerdido','Incluir')">Salvar</button>
javascript
function sub(arquivo, acao) {
$("#form").submit(function (e) {
var formData = new FormData($(this)[0]);
formData.append("acao", acao);
formData.append("arquivo", arquivo);
jQuery.ajax({
type: 'POST',
mimeType: "multipart/form-data",
url: 'model/acao/controller.php',
dataType: 'json',
data: formData,
async: false,
cache: false,
contentType: false,
processData: false
}).done(function (html) {
console.log(html);
});
});
}
Form inserting twice in bank F5
– rray
You want to wait to finish the first request so the user can save again?
– Laerte
@rray that’s not what I’m doing with ajax if updating the page can’t happen anything but clear the form
– Herick
@Laerte The problem is that it is saving more than once in the bank with a single click on the button as described in the problem
– Herick