Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/07/2010, 09:02
Avatar de neodani
neodani
 
Fecha de Ingreso: marzo-2007
Mensajes: 1.811
Antigüedad: 17 años, 2 meses
Puntos: 20
Cómo hacer un preloader

Buenas,

Me gustaría cargar unos datos de una página web y mientras se cargan me gustaría mostrar el tipico mensaje de cargando.

Lo he probado de muchas maneras pero no consigo que funcione correctamente.

Podéis decirme que hago mal?

Código Javascript:
Ver original
  1. <html>
  2. <head>
  3. <title>PRELOADER 1</title>
  4. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
  5. <style>
  6.  
  7.  
  8. </style>
  9. <script language="javascript">
  10.  
  11. $('#boton_cargar').click(function(){
  12.     $("#seccion").load("pagina-lenta.php",function(){
  13.         $('#loading').fadeOut('slow', function() {
  14.             $(this).remove();
  15.         });
  16.     });
  17. });
  18.  
  19.  
  20. $('#loading')
  21.     .hide()  // hide it initially
  22.     .ajaxStart(function() {
  23.         $(this).fadeIn('slow')
  24.         $(this).animate({opacity: 1.0}, 3000)
  25.     })
  26.     .ajaxStop(function() {
  27.         $(this).fadeOut('slow', function() {
  28.             $(this).remove();
  29.         });
  30. });
  31. </script>
  32. </head>
  33. <body>
  34.  
  35. <div id="loading">Cargando.....</div>
  36.  
  37. <a href="#" id="boton_cargar">Cargar datos</a>
  38. <div id="seccion"></div>
  39.  
  40.  
  41. </body>
  42. </html>

Muchas gracias de antemano!