Ver Mensaje Individual
  #3 (permalink)  
Antiguo 04/10/2012, 09:51
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......

He puesto esta función en mi cod pero no va.

Código Javascript:
Ver original
  1. (function($){
  2. $('button#btnfiltrar').on('click',function(e){
  3.     var $contenidoAjax = $('div#contenidoAjax').html('<p><img src="http://www.funcion13.com/wp-content/uploads/2012/04/loader.gif" /></p>');
  4.    
  5.     // Simulo una petición AJAX de 3 segundos
  6.     setTimeout(function(){
  7.         $contenidoAjax.html('<p>¡¡Contenido cargado!!</p>');
  8.     }, 3000);
  9.     e.preventDefault();
  10. });
  11. })(jQuery);

El botón que tengo en el formulario es:

Código PHP:
<th scope="col"><button type="button"  id="btnfiltrar" name="btnfiltrar" style="border:0; margin:0; padding:0;cursor:pointer">
  <
img src="imagenes_menu/boton_buscar.png"/>
</
button
Y el cod completo es:

Código Javascript:
Ver original
  1. // JavaScript Document
  2. var ordenar = '';
  3. $(document).ready(function(){
  4.    
  5.     // Llamando a la funcion de busqueda al
  6.     // cargar la pagina
  7.     filtrar()
  8.    
  9.     var dates = $( "#del, #al" ).datepicker({
  10.             yearRange: "-50",
  11.             defaultDate: "+1w",
  12.             changeMonth: true,
  13.             changeYear: true,
  14.             onSelect: function( selectedDate ) {
  15.                 var option = this.id == "del" ? "minDate" : "maxDate",
  16.                     instance = $( this ).data( "datepicker" ),
  17.                     date = $.datepicker.parseDate(
  18.                         instance.settings.dateFormat ||
  19.                         $.datepicker._defaults.dateFormat,
  20.                         selectedDate, instance.settings );
  21.                 dates.not( this ).datepicker( "option", option, date );
  22.             }
  23.     });
  24.    
  25.     // filtrar al darle click al boton
  26.     $("#btnfiltrar").click(function(){ filtrar() });
  27.    
  28.     // boton cancelar
  29.     $("#btncancel").click(function(){
  30.         $(".filtro input").val('')
  31.         $(".filtro select").find("option[value='0']").attr("selected",true)
  32.         filtrar()
  33.     });
  34.    
  35.     // ordenar por
  36.     $("#data th span").click(function(){
  37.         var orden = '';
  38.         if($(this).hasClass("desc"))
  39.         {
  40.             $("#data th span").removeClass("desc").removeClass("asc")
  41.             $(this).addClass("asc");
  42.             ordenar = "&orderby="+$(this).attr("title")+" asc"     
  43.         }else
  44.         {
  45.             $("#data th span").removeClass("desc").removeClass("asc")
  46.             $(this).addClass("desc");
  47.             ordenar = "&orderby="+$(this).attr("title")+" desc"
  48.         }
  49.         filtrar()
  50.     });
  51. });
  52. (function($){
  53. $('button#btnfiltrar').on('click',function(e){
  54.     var $contenidoAjax = $('div#contenidoAjax').html('<p><img src="http://www.funcion13.com/wp-content/uploads/2012/04/loader.gif" /></p>');
  55.    
  56.     // Simulo una petición AJAX de 3 segundos
  57.     setTimeout(function(){
  58.         $contenidoAjax.html('<p>¡¡Contenido cargado!!</p>');
  59.     }, 3000);
  60.     e.preventDefault();
  61. });
  62. })(jQuery);
  63.  
  64. var fila= null;
  65. function pulsar(obj, num_usuario) {
  66.   obj.style.background = 'orange';
  67.   if (fila != null && fila != obj)
  68.     fila.style.background = 'white';
  69.   fila = obj;
  70.  window.location ="menu1.php?id="+num_usuario;
  71. }
  72.  
  73. function filtrar()
  74. {  
  75.     $.ajax({
  76.         data: $("#frm_filtro").serialize()+ordenar,
  77.         type: "POST",
  78.         dataType: "json",
  79.         url: "ajax.php?action=listar",
  80.             success: function(data){
  81.     var html_user ='' ;
  82.     if(data.length > 0){
  83.         $.each(data, function(i,item){
  84.        
  85.        
  86.          
  87.  html_user += '<tr ondblclick="pulsar(this, ' +  String.fromCharCode(39) + item.num_usuario + String.fromCharCode(39)  + ');" >';
  88.  html_user += '<td ><input name="demo" type="radio" value="' + item.num_usuario + '"/></td>';
  89.  html_user += '<td id="row0" >'+item.num_usuario+'</td>';
  90.  html_user += '<td>'+item.telefono+'</td>';
  91.  html_user += '<td>'+item.nombre+' '+item.apellidos+'</td>';
  92.  html_user += '<td>'+item.poblacion+'</td>';
  93.  html_user += '</tr>';
  94.            
  95.                                  
  96.         });                    
  97.     }
  98.     if(html_user == '') html_user = '<tr><td colspan="4" align="center">No se encontraron registros..</td></tr>';
  99.     $("#data tbody").html(html_user);
  100. }
  101.  
  102.            
  103.       });
  104. }
  105.  
  106. function createAjax(){
  107.    if (window.XMLHttpRequest)
  108.    {
  109.       xmlhttp=new XMLHttpRequest();
  110.    }
  111.    else
  112.    {
  113.       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  114.    }
  115. }
  116.  
  117. function buscarAparatos()
  118. {
  119.     var num_usuario = 0;
  120.     var elements = document.getElementsByName('demo');
  121.    
  122.     for(var x=0;elements[x];x++){
  123.         if(elements[x].checked){
  124.             num_usuario = elements[x].value;
  125.             break;
  126.         }
  127.     }
  128.    
  129.     createAjax();
  130.     xmlhttp.onreadystatechange=function()
  131.     {
  132.         if (xmlhttp.readyState==4 && xmlhttp.status==200)
  133.         {
  134.             document.getElementById("pestaña1").innerHTML=xmlhttp.responseText;
  135.         }
  136.     }
  137.    xmlhttp.open("GET","listado_aparatos.php?ID=" + num_usuario,true);
  138.    xmlhttp.send(null);
  139. }