Ver Mensaje Individual
  #8 (permalink)  
Antiguo 20/03/2011, 17:33
Avatar de hmvr414
hmvr414
 
Fecha de Ingreso: marzo-2011
Ubicación: Santiago de Cali, Colombia
Mensajes: 74
Antigüedad: 13 años, 1 mes
Puntos: 16
Respuesta: Enviar form por ajax y jquery con funcion desde enlace

Prueba este ejemplo:

archivo formulario.html
Código HTML:
Ver original
  1. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
  2. <script type="text/javascript">
  3.     $(document).ready(function () {
  4.    
  5.         $("#formulario").submit(function (ev) {
  6.             var $frm = $(this);
  7.             ev.preventDefault();
  8.            
  9.             $.ajax({
  10.            
  11.                 type: $frm.attr("method"),
  12.                 url: $frm.attr("action"),
  13.                 data: $frm.serialize(),
  14.                 success: function (data) {
  15.                     $("#resultado").append(data);
  16.                 }
  17.             });
  18.         });
  19.     });
  20. </head>
  21.     <form id="formulario" action="procesar.php" method="POST">
  22.         <input name="datoA" type="text" value="" />
  23.         <input name="datoB" type="text" value="" />
  24.         <input name="submit" type="submit" value="Enviar" />
  25.     </form>
  26.     <div id="resultado"></div>
  27. </body>
  28. </html>

archivo procesar.php:
Código PHP:
Ver original
  1. <?php
  2.     var_dump($_POST);