Jquery ajax get - how to output data based on condition?
Posted
by
arunas_t
on Stack Overflow
See other posts from Stack Overflow
or by arunas_t
Published on 2011-01-14T07:48:23Z
Indexed on
2011/01/14
7:53 UTC
Read the original article
Hit count: 154
jquery-ajax
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.
© Stack Overflow or respective owner