Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/03/2011, 06:58
ZeThito
 
Fecha de Ingreso: septiembre-2010
Mensajes: 147
Antigüedad: 13 años, 7 meses
Puntos: 3
Subir un archivo con jQuery.

Hola :)

He intentado subir un archivo utilizando jQuery con serialize(), pero tengo malos resultados.

Este es mi código jQuery:

Código Javascript:
Ver original
  1. <script type="text/javascript">
  2. $(document).ready(function(){
  3.    
  4.     $('#formID').submit(function(e) {
  5.  
  6.         Registrar();
  7.         e.preventDefault();
  8.        
  9.     });
  10.    
  11. });
  12.  
  13. function Registrar()
  14. {
  15.     hideshow('loading',1);
  16.     error(0);
  17.    
  18.     $.ajax({
  19.        
  20.         type: "POST",
  21.         url: "/web/controlador/enviarPublicacion.php",
  22.         data: $('#formID').serialize(),
  23.         dataType: "json",
  24.         success: function(msg){
  25.            
  26.             if(parseInt(msg.status)==1)
  27.             {
  28.                 $('#formReg').find('dl').slideUp('normal', function(msg){
  29.                     $('#formReg').html('<h1>Muchas Gracias</h1> <p>Se ha enviado el enlace de Activación y Contraseña a su Correo Electrónico. <br></p>');
  30.                 });
  31.             }
  32.             else if(parseInt(msg.status)==0)
  33.             {
  34.                 error(1,msg.txt);
  35.             }
  36.            
  37.             hideshow('loading',0);
  38.         }
  39.     });
  40.  
  41. }
  42.  
  43. function hideshow(el,act)
  44. {
  45.     if(act) $('#'+el).css('visibility','visible');
  46.     else $('#'+el).css('visibility','hidden');
  47. }
  48.  
  49. function error(act,txt)
  50. {
  51.     hideshow('error',act);
  52.     if(txt) $('#error').html(txt);
  53. }
  54.  
  55. </script>

He leído en está pagina que se puede lograr con tal plugins : http://malsup.com/jquery/form/#file-upload

Alguien me puede ayudar para acoplar el plugins de Malsup en mi código?
No quiero modificar todo mi código :(

Saludos y espero de su ayuda!

Última edición por ZeThito; 02/03/2011 a las 07:04