1
I have a While loop in my php that contains to pick variables through POST with the plugin serializeToJSON.
It works in part, but it always takes the last result of the PHP loop with the inputs, when it should take all the inputs of the loop, for example
I have this loop
<form>
<input type="hidden" name="id_i" id="id_i" value="<?php echo $id_i; ?>">
<input type="hidden" name="id_usuario" id="id_usuario" value="<?php echo $id_usuario; ?>"/>
<input type="hidden" name="auxiliar_fornecedor" id="auxiliar_fornecedor" value="<?php echo $produto["auxiliar"]; ?>">
<div class="number" data-last="<?php echo substr($produto ["telefone"], 6, 6); ?>"><i class="fa fa-phone" aria-hidden="true"></i> <?php echo substr($produto ["telefone"], 0, 6); ?><span><strong>Clique aqui para ver o número</strong></span></div>
</form>
Javascript will always take the last loop record How could I make it so that every time I click on the div class="number" of the php loop I send all the variables to the php file "meu_ajax.php"?
Code java Script $('. number'). click(Function(Ev) { $(this). find('span'). text( $(this). data('last') ); $.ajax({ type: "POST", url:'meu_ajax.php', date: $("form"). serialize(), error: Function() { Alert('Error'); } }); });
– Wagner Martins Bodyboard
Could show the part that used the serializeToJSON?
– Guilherme Nascimento
$('.number'). click(Function(Ev) { $(this). find('span'). text( $(this).data('last') ); $.ajax({ type: "POST", url:'meu_ajax.php', date: $("form").serialize(), error: Function () { Alert('Error'); } }); a}); });
– Wagner Martins Bodyboard
But the plugin you quoted?
– Guilherme Nascimento