Ver Mensaje Individual
  #17 (permalink)  
Antiguo 11/10/2012, 12:27
Avatar de satjaen
satjaen
 
Fecha de Ingreso: septiembre-2012
Ubicación: Jaén (Andalucía)
Mensajes: 893
Antigüedad: 11 años, 7 meses
Puntos: 10
Respuesta: Imagen animada al llamar al servidor

Si, pero lo que pasa que si le pongo la class="carga" la imagen empieza a salir nada mas ver el formulario y no cuando le das al boton de busqueda.
A lo mejor hay que poner tambien una funcion para que salga la imagen cuando se le de a dicho boton de busqueda no?
Y otra cosa no puede ser que el <th><div id="carga" class="carga"></div></th>, tenga que ir en la parte de:

Código Javascript:
Ver original
  1. }
  2.     if(html_user == '') html_user = '<tr><td colspan="4" align="center">No se encontraron registros..</td></tr>';
  3.     $("#data tbody").html(html_user);
  4.     $('.carga').html('');
  5. }
Porque aquí es donde me salen los registros que recojo y es donde debería de salir la imagen animada antes de nada?




Lo he dejado así:

Código Javascript:
Ver original
  1. function filtrar()
  2.  
  3. {
  4.  
  5.      $.ajax({
  6.  data: $("#frm_filtro").serialize()+ordenar,
  7.  type: "POST",
  8.  dataType: "json",
  9.  url: "ajax.php?action=listar",
  10.  beforeSend: function(){
  11.  $('.carga').html("<img src='imagenes_menu/ajax-loader3.gif' align='center' /><br /> Aguarde por favor...");
  12.  },
  13. success: function(data){
  14.         var html_user ='' ;
  15.         if(data.length > 0){
  16.         $.each(data, function(i,item){
  17.        
  18.        
  19.          
  20.  html_user += '<tr ondblclick="pulsar(this, ' +  String.fromCharCode(39) + item.num_usuario + String.fromCharCode(39)  + ');" >';
  21.  html_user += '<td ><input name="demo" type="radio" value="' + item.num_usuario + '"/></td>';
  22.  html_user += '<td id="row0" >'+item.num_usuario+'</td>';
  23.  html_user += '<td>'+item.telefono+'</td>';
  24.  html_user += '<td>'+item.nombre+' '+item.apellidos+'</td>';
  25.  html_user += '<td>'+item.poblacion+'</td>';
  26.  html_user += '</tr>';
  27.            
  28.                                  
  29.         });                    
  30.     }
  31.     if(html_user == '') html_user = '<tr><td colspan="4" align="center">No se encontraron registros..</td></tr>';
  32.     $("#data tbody").html(html_user);
  33.     $('.carga').html('');
  34. }
  35.  
  36.            
  37.       });
  38. }



Código Javascript:
Ver original
  1. <table width="100%" id="data" class="table-dg-grid" >
  2.              <thead>
  3.               <tr>
  4.           <th><div id="carga" class="carga"></div></th>
  5.           <tr bgcolor=#DFEBFF id=t70 ondblclick='coloreaf(70,1)' onMouseOver='coloreamosin(70,1)' onMouseOut='coloreamosout(70,1)'>
  6.           <th><span title="selecc">Selecc.</span></th>
  7.           <th><span title="nu_usuario">Nº Usuario</span></th>
  8.           <th><span title="telefono">Teléfono</span></th>
  9.           <th><span title="nombre">Nombre</span></th>
  10.           <th><span title="poblacion">Población</span></th>
  11.              </tr>
  12.             </thead>
  13.                 <tbody>
  14.                 </tbody>
  15.             </table>