I have a request problem
When I click on the save button it does 1 request or it is saved 1 time in the bank if it clicks again it does 2 in one time saving 2 times in the bank clicking again it does 3 in one time saving 3 times in the database .
I need 1 per click.
follow 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);
});
});
}