Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/01/2013, 13:49
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
Dirigir a otra página si no encuentra registros.

Hola, por favor tengo este cod que detallo y lo que quiero es que cuando al filtrar los datos no se encuentren registros:
Código PHP:
if(html_user == ''html_user '<tr><td colspan="4" align="center">No se encontraron registros..</td></tr>'
me dirija a otra página llamada ingresos.php con un alert.

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.      $('.carga1').css('display','block');
  12.         $('.carga1').html("<img src='imagenes_menu/ajax-loader4.gif' align='center' /><br />Cargando...");
  13.         },  
  14.         complete: function() {
  15.  
  16.             $(".carga1").show();
  17.  
  18.             $(".carga1").hide();
  19.  
  20.         },            
  21.         success: function(data){
  22.         var html_user ='' ;
  23.         if(data.length > 0){
  24.         $.each(data, function(i,item){
  25.        
  26.        
  27.          
  28.  html_user += '<tr ondblclick="pulsar(this, ' +  String.fromCharCode(39) + item.id_aviso + String.fromCharCode(39)  + ');" >';
  29.  html_user += '<td ><input name="demo" type="radio" value="' + item.id_aviso + '"/></td>';
  30.  html_user += '<td>'+item.id_aviso+'</td>';
  31.  html_user += '<td>'+item.telefonos+'</td>';
  32.  html_user += '<td>'+item.name+' '+item.apellidos+'</td>';
  33.  html_user += '<td>'+item.localidad+'</td>';
  34.  html_user += '</tr>';
  35.            
  36.                                  
  37.         });                    
  38.     }
  39.     if(html_user == '') html_user = '<tr><td colspan="4" align="center">No se encontraron registros..</td></tr>';
  40.     $("#data tbody").html(html_user);
  41.     $('.carga').html('');
  42. }
  43.  
  44.            
  45.       });
  46. }

Se puede hacer?
Gracias