Jquery ajax get - how to output data based on condition?
- by arunas_t
Hello, there, I have a such piece of code:
$("#choose").change(function(){
$.get("get_results.php", {name: $("#choose").val()},
function(data){
if(data !== ""){
$("#results").html(data);
}else{
$("#results").html('<strong>Sorry, no records.</strong>');
}
});
});
Now the problem is that the first condition ( if(data !== "") ) is always evaluated correctly and executed, but the else clause ('Sorry, no records') never shows up. Can anyone spot the error? Data passed for the else clause is specifically "". Thank You.