samedi 28 novembre 2015

Using javascript to send an object through a form

I'm stuck trying to pass an object to another page , using javascript. I hope you can give me a hand . Thanks.

Here the object created and sent through a form and input.

var cars = {nombre : "luis", apellido: "heya"};

var form = '<form action="RegisterOrder.php" method="post">'+'<input type="hidden" name="arrayDatosProductos" value="'+cars+'"></input>'+'</form>';
$(form).submit();

In the page that receives the object :

var a = new Object(<?php echo $_REQUEST['arrayDatosProductos']; ?>);
alert(a.nombre);




Aucun commentaire:

Enregistrer un commentaire