3
I’m trying to send data from a form to another page, and bring from it a chart in a div with id="return", which is below the form.
The form has the code, data1, data2 and store, but it seems that the variables are not being sent correctly.
I’ve done something similar but only with one variable, but with several like.
My job jQuery is down, I believe there’s something wrong with it.
I found several examples on the internet, but none helped me and solved my problem.
$(document).ready(function() {
//alert("teste 1 ");
/// Quando usuário clicar no botão será feito todos os passo abaixo
$('#formulario').submit(function() {
//alert("teste 2");
var codigo = $('#codigo').val();
var data1 = $('#data1').val();
var data2 = $('#data2').val();
var loja = $('#loja').val();
$.ajax({
type: 'POST',
dataType: 'json',
url: 'retorna_produto.php',
async: true,
data: {codigo, data1, data2, loja},
//data: {'codigo='+ $('#codigo').val(),
// 'data1='+ $('#data1').val(),
// 'data2='+ $('#data2').val(),
// 'loja='+ $('#loja').val()
//},
success: function(data) {
$('#retorno').html(data);
}
});
return false;
});
});
I’ll test it, thank you.
– Andre Hoffmann
It worked, thanks, the only thing I changed was dataType: 'json', which I had to put dataType: 'html', otherwise it wouldn’t work.
– Andre Hoffmann