Ver Mensaje Individual
  #8 (permalink)  
Antiguo 09/07/2010, 07:21
ecastaneda
 
Fecha de Ingreso: julio-2010
Mensajes: 14
Antigüedad: 13 años, 9 meses
Puntos: 1
Respuesta: Enviar variables con ajax

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("|")[1];
  13.      
  14.      }
  15.   });
  16. }
  17. </head>
  18. <form action="" method="POST">
  19. nombre: <input name="nombre" id="nombre" type="text" value="1"/></br>
  20. apellido: <input name="apellido" id="apellido" type="text" value="1"/></br>
  21. <input type="submit" value="Enviar"/>
  22. <input type="button" value="Automatico" onclick="buscar();"/>
  23. </form>
  24. </body>
  25. </html>
haber cala ese le hacia falta una llave . . .