Ver Mensaje Individual
  #5 (permalink)  
Antiguo 10/10/2012, 01:26
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

Explico un poco lo que quiero hacer:
Tengo un formulario con varios campos y un boton para hacer una busqueda por nº de telefono, localidad etc.., el cual tiene un boton y debajo de este formulario tengo un tabla que por medio de ajax recupero los resultados de la consulta php a la base de datos.

Este es parte del formulario:

Código HTML:
Ver original
  1. <div id="formulario">
  2.     <form id="frm_filtro" method="post" action="" name="form1">
  3.             <table width="685">
  4.   <tr>
  5.     <td width="9%" class="campo_apellidos2">Teléfonos</td>
  6.     <td width="9%"><input name="telefono" type="text" size="9" /></td>
  7. </tr>
  8.      <tr>
  9.     <td class="campo_apellidos2">Localidad</td>
  10.     <td colspan="4"><input name="poblacion" type="text" size="30" />
  11.       </tr>
  12.  
  13.  <th scope="col"><button type="button"  id="btnfiltrar" name="btnfiltrar" style="border:0; margin:0; padding:0;cursor:pointer">
  14.   <img src="imagenes_menu/boton_buscar.png"/>
  15. </th>
  16.   </tr>
  17. </table>                
  18.           </form>

Aquí en esta la tabla donde recupero los resultados:

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



y me falta el archivo js que es donde quiero que al darle al boton de busqueda me haga la tipica imagen animada de busqueda Loading............



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


Por favor, si no me he explicado con claridad decirmelo.Gracias