I have the following Form:
<div class="row" id="importar">
<form id="convidados">
<input type="hidden" value="<?php echo $this->uri->segment(4); ?>" id="id_cliente" name="id_cliente">
<div id="multiple_upload">
<input type="file" id="uploadChange" onchange="checkfile(this);" />
<div id="message">Selecione o Arquivo</div>
<input type="button" id="botao_" class="btn btn-primary" value="Importar" disabled />
<div id="lista">
</div>
</div>
</form>
<div>
And jQuery:
// importar
$(function () {
var form;
$('#uploadChange').change(function (event) {
form = new FormData();
form.append('uploadChange', event.target.files[0]); // para apenas 1 arquivo
//var name = event.target.files[0].content.name; // para capturar o nome do arquivo com sua extenção
});
$('#botao_').click(function () {
var id_cliente = $("#id_cliente").val();
$.ajax({
url: basePath + 'ajax/importar_lista',
data: {upload: form, id_cliente: id_cliente},
processData: false,
contentType: false,
type: 'POST',
success: function (data) {
console.log("success");
$('#importar').html("<div style='padding: 100px;'><center><img src='../../../assets/img/importando-lista.gif'></center></div>");
setTimeout(function(){
$('#importar').html(data);
},3000);
}
});
});
});
I need to add the following variable to pass on in ajax / import_list:
var id_cliente = $("#id_cliente").val();
How can I pass id_cliente
inside ajax? If I go over as the answer from @KayoBruno, I need to go over with var?