serializeToJSON does not send variables to php

Asked

Viewed 23 times

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'); } }); });

  • Could show the part that used the serializeToJSON?

  • $('.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}); });

  • But the plugin you quoted?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.