Ver Mensaje Individual
  #12 (permalink)  
Antiguo 05/10/2012, 01:15
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: Funcion Load cargar......

Buenos dias, he puesto este cod, pero donde tengo que ponerlo en la cabecera del index, o en js que he puesto al principio de la consulta?. Y el div donde me va a salir la imagen de cargando le tengo que poner el nombre que yo quiera o tiene que ir en un sitio en especial?


Código Javascript:
Ver original
  1. $(document).ready(function(){
  2.  
  3.   $("div").ajaxStart(function(){
  4.  
  5.     $(this).html("<img src='imagenes_menu/ajax-loader1.gif' />");
  6.  
  7.   });
  8.  
  9.   $("button").click(function(){
  10.  
  11.     $("div").load("demo_ajax_load.asp");
  12.  
  13.   });
  14.  
  15. });



Código Javascript:
Ver original
  1. function filtrar()
  2. {  
  3.     $.ajax({
  4.         data: $("#frm_filtro").serialize()+ordenar,
  5.         type: "POST",
  6.         dataType: "json",
  7.         url: "ajax.php?action=listar",
  8.             success: function(data){
  9.            
  10.  
  11. $(document).ready(function(){
  12.  
  13.   $("div").ajaxStart(function(){
  14.  
  15.     $(this).html("<img src='imagenes_menu/ajax-loader1.gif' />");
  16.  
  17.   });
  18.  
  19.   $("button").click(function(){
  20.  
  21.     $("div").load("demo_ajax_load.asp");
  22.  
  23.   });
  24.  
  25. });
  26.  
  27.     var html_user ='' ;
  28.     if(data.length > 0){
  29.         $.each(data, function(i,item){
  30.        
  31.        
  32.          
  33.  html_user += '<tr ondblclick="pulsar(this, ' +  String.fromCharCode(39) + item.num_usuario + String.fromCharCode(39)  + ');" >';
  34.  html_user += '<td ><input name="demo" type="radio" value="' + item.num_usuario + '"/></td>';
  35.  html_user += '<td id="row0" >'+item.num_usuario+'</td>';
  36.  html_user += '<td>'+item.telefono+'</td>';
  37.  html_user += '<td>'+item.nombre+' '+item.apellidos+'</td>';
  38.  html_user += '<td>'+item.poblacion+'</td>';
  39.  html_user += '</tr>';
  40.            
  41.                                  
  42.         });                    
  43.     }
  44.     if(html_user == '') html_user = '<tr><td colspan="4" align="center">No se encontraron registros..</td></tr>';
  45.     $("#data tbody").html(html_user);
  46. }
  47.  
  48.            
  49.       });
  50. }
  51.  
  52. function createAjax(){
  53.    if (window.XMLHttpRequest)
  54.    {
  55.       xmlhttp=new XMLHttpRequest();
  56.    }
  57.    else
  58.    {
  59.       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  60.    }
  61. }
  62.  
  63. function buscarAparatos()
  64. {
  65.     var num_usuario = 0;
  66.     var elements = document.getElementsByName('demo');
  67.    
  68.     for(var x=0;elements[x];x++){
  69.         if(elements[x].checked){
  70.             num_usuario = elements[x].value;
  71.             break;
  72.         }
  73.     }
  74.    
  75.     createAjax();
  76.     xmlhttp.onreadystatechange=function()
  77.     {
  78.         if (xmlhttp.readyState==4 && xmlhttp.status==200)
  79.         {
  80.             document.getElementById("pestaña1").innerHTML=xmlhttp.responseText;
  81.         }
  82.     }
  83.    xmlhttp.open("GET","listado_aparatos.php?ID=" + num_usuario,true);
  84.    xmlhttp.send(null);
  85. }

y tampoco se donde poner esto que me dices en mi código:


Código Javascript:
Ver original
  1. $('#carga').ajaxStart(function() {
  2. * * $(this).append('Cargando ...');
  3. });
  4. $('#carga').ajaxComplete(function() {
  5. * * $(this).append('Se completo la carga');
  6. });
  7. *
  8. $.ajax({
  9. *
  10. });

Última edición por satjaen; 05/10/2012 a las 09:13