Hello good day I have a question about how to make an error or an exception in Ajax.
When I select a city that does not have zones, (records in BD) I require an error message to appear.
However, currently the program brings the select
empty
How can I make an exception to be thrown if the function returns data, so the Ajax comparison of if(!datos)
does not work.
function obtenerZonas(ciudad) {
$.ajax({
url : "obtenerZonas.jsp?v_ciu=" + ciudad, /* se envia por GET */
cache: false,
dataType : 'html',
success : function(datos) {
if(!datos){
$("#erroro").html("La ciudad Seleccionada No tiene Zonas. Error"+ ciudad );
}else{
$('#zona').html(datos);
}
},
error: function( ) {
$("#errorz").html("Se presento un problema, Ciudad No. = " + ciudad);
}
});
}
The solution should be something like this:
My problem is that the error jumps in the new comparison because the value is null ...
But when the problem occurs in a microzone ... there is no way to validate the error, what should I do?
I hope you made me understand .. !!
Thanks !!