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 originalhtml_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 originalfunction filtrar()
{
$.ajax({
data: $("#frm_filtro").serialize()+ordenar,
type: "POST",
dataType: "json",
url: "ajax.php?action=listar",
beforeSend:function(){
$('.carga1').css('display','block');
$('.carga1').html("<img src='imagenes_menu/ajax-loader4.gif' align='center' /><br />Cargando...");
},
complete: function() {
$(".carga1").show();
$(".carga1").hide();
},
success: function(data){
var html_user ='' ;
if(data.length > 0){
$.each(data, function(i,item){
html_user += '<tr ondblclick="pulsar(this, ' + *String.fromCharCode(39) + item.id_aviso + String.fromCharCode(39) *+ ');" >';
html_user += '<td style="'+item.style+'"><input name="demo" type="radio" value="' + item.id_aviso + '"/></td>';
html_user += '<td style="'+item.style+'">'+item.id_aviso+'</td>';
html_user += '<td style="'+item.style+'">'+item.telefonos+'</td>';
html_user += '<td style="'+item.style+'">'+item.name+' '+item.apellidos+'</td>';
html_user += '<td style="'+item.style+'">'+item.calle+'</td>';
html_user += '<td style="'+item.style+'">'+item.localidad+'</td>';
html_user += '</tr>';
});
}
if(html_user == '')
html_user = '<tr><td colspan="4" align="center">No se encontraron registros..</td></tr>';
$("#data tbody").html(html_user);
$('.carga').html('');
if(data.length=='0'){
var telefonos = document.getElementsByName('telefonos');
if (confirm("¿Nuevo Cliente?")) {
if (document.form12.telefonos.value=="")
{
alert("¡Ingrese nº de teléfono!");
document.form12.telefonos.focus; // posicionas el puntero en ese campo
return false;//le dices q no envie nada
}
document.forms['form12'].submit();
} else {
return false;
}
}
}
});
}
Gracias