Well, I am trying to create a condition where if a select element is empty, deny the call to a function made in ajax, but my problem is that I do not know exactly how to create that condition. Here is my code attempt.
function LimpiaEstado() {
var Pais = document.getElementById('ddl_Perfil_Pais').value;
if (Pais = ''){
ddl_Perfil_Estado.html('');
//Aqui intento negar la funcion CatEstado en caso de que este vacio
}
function CatEstado(Pais) {
$.ajax({
url: 'Talento.ashx?Tipo=Estados&Pais=' + Pais,
dataType: 'JSON',
type: 'POST',
async: false,
contentType: "application/json; charset=utf-8",
success: function (data) {
$('#ddl_Perfil_Estado').html('');
$('#ddl_Perfil_Estado').append('<option value=""> Selecciona..</option>');
$.each(data.DatosCatalogoEstado, function (key, val) {
$('#ddl_Perfil_Estado').append('<option value="' + val.ID + '">' + val.ESTADO + '</option>');
})
$('#ddl_Perfil_Estado').selectpicker('refresh');
},
error: function (response) {
$('#ddl_Perfil_Estado').html('<option id="-1">none available</option>');
}
});
}
If you know how to do it directly with Ajax, it would be equally helpful, or if you know how to do it, without necessarily being a condition. Any suggestion or advice is welcome.