Ver Mensaje Individual
  #5 (permalink)  
Antiguo 08/07/2010, 14:46
canino_latino
 
Fecha de Ingreso: enero-2010
Mensajes: 113
Antigüedad: 14 años, 3 meses
Puntos: 2
Respuesta: Enviar variables con ajax

Bueno mira hice lo que dices:

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <script type="text/javascript" language="javascript" src="js/jquery.js"></script>
  3. function buscar(){
  4. $.ajax({
  5.    type: "POST",
  6.    url: "canal.php",
  7.    data: "nombre=canino&apellido=latino",
  8.   success: function(respServ){
  9.        //msg trai lo que  yourfile.php respondio osea que yourfile.php debe hacer solo  por decirlo haci un echo $nombre .'|'.$apellido; entonces tu haria lo siguiente
  10.  
  11.            documen.getElementById("nombre").value=respServ.split("|")[0];
  12.            documen.getElementById("apellido").value==respServ.split("|")[0];
  13.  
  14.    }
  15.  });
  16. </head>
  17. <form action="" method="POST">
  18. nombre: <input name="nombre" id="nombre" type="text" value="1"/></br>
  19. apellido: <input name="apellido" id="apellido" type="text" value="1"/></br>
  20. <input type="submit" value="Enviar"/>
  21. <input type="button" value="Automatico" onclick="buscar();"/>
  22. </form>
  23. </body>
  24. </html>

y este es canal.php:

Código PHP:
Ver original
  1. <?php
  2. echo $_POST["nombre"]."|";
  3. echo $_POST["apellido"];
  4. ?>

y no funciona.

no entiendo porque.

Gracias espero puedas ayudarme.