The ajax call snipet below returns either ‘found’ or ‘no’ as a string from the server. The first line of the callback alert(d) shows the result returned. However, the line if (d == "found") is never true, even when ‘found’ is returned. Please what am I missing? Thanks for the help.
$.get('includes/reg_fns.php', {
'op': 'availability',
'field': $(this).attr('name'),
'val': val
}, function(d) {
alert(d);
if (d == "found") {
alert("<br /><span style='font-size:83%;color:red; margin-left:117px'> [ <b>*</b> " + val + " is already taken.</span><br />");
} else {
alert('false here');
}
});
may be you are returning with extra space on it.
try using trim() on it.