Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/02/2013, 04:55
Avatar de satjaen
satjaen
 
Fecha de Ingreso: septiembre-2012
Ubicación: Jaén (Andalucía)
Mensajes: 893
Antigüedad: 12 años, 5 meses
Puntos: 10
No veo donde esta el error.

Hola, tengo este cod pero no veo donde esta mi error y es que cuando no hay registros en el ajax.php no me sale el valor de la variable:

Código HTML:
Ver original
  1. html_user = '<tr><td colspan="4" align="center">No se encontraron registros..</td></tr>';

y claro ya no sigue el código. Por favor si veis algo raro me lo podeis decir?

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. beforeSend:function(){
  10. $('.carga1').css('display','block');
  11. $('.carga1').html("<img src='imagenes_menu/ajax-loader4.gif' align='center' /><br />Cargando...");
  12.  },
  13. complete: function() {
  14. $(".carga1").show();
  15. $(".carga1").hide();
  16. },
  17. success: function(data){
  18. var html_user ='' ;
  19. if(data.length > 0){
  20. $.each(data, function(i,item){
  21.  
  22. html_user += '<tr ondblclick="pulsar(this, ' + *String.fromCharCode(39) + item.id_aviso + String.fromCharCode(39) *+ ');" >';
  23. html_user += '<td style="'+item.style+'"><input name="demo" type="radio" value="' + item.id_aviso + '"/></td>';
  24. html_user += '<td  style="'+item.style+'">'+item.id_aviso+'</td>';
  25. html_user += '<td  style="'+item.style+'">'+item.telefonos+'</td>';
  26. html_user += '<td  style="'+item.style+'">'+item.name+' '+item.apellidos+'</td>';
  27. html_user += '<td  style="'+item.style+'">'+item.calle+'</td>';
  28. html_user += '<td  style="'+item.style+'">'+item.localidad+'</td>';
  29. html_user += '</tr>';
  30.  
  31. });
  32.  }
  33. if(html_user == '')
  34.     html_user = '<tr><td colspan="4" align="center">No se encontraron registros..</td></tr>';
  35. $("#data tbody").html(html_user);
  36. $('.carga').html('');
  37.    
  38.    if(data.length=='0'){
  39.        var telefonos = document.getElementsByName('telefonos');
  40.        
  41.       if (confirm("¿Nuevo Cliente?")) {
  42.            
  43.          if (document.form12.telefonos.value=="")
  44.    {
  45.              alert("¡Ingrese nº de teléfono!");
  46.              document.form12.telefonos.focus; // posicionas el puntero en ese campo
  47.              return false;//le dices q no envie nada
  48.          }
  49.          document.forms['form12'].submit();
  50.                  
  51.       } else {
  52.      
  53.          return false;    
  54.       }
  55. }
  56.   }
  57.        
  58.   });
  59.    }

Gracias

Última edición por satjaen; 22/02/2013 a las 06:07