In jquery ajax function I recive to the server "true" or "false" strings. Then I only wnat know result but only get false in if condition.
$.ajax({
...
success: function(result) {
if(result == "true"){ // false???????
alert('true');
} else {
alert('false');
}
}
})
...
$.ajax({
...
success: function(result) {
var result2 = String(result);
alert(result2); // true
alert(typeof result2); // String
alert(typeof "true"); // String
if(result2 == "true"){ // false???????
alert('true');
} else {
alert('false');
}
}
})
...
...
Somebody can help me?
result == "true"isfalsethenresultis not"true". Simple as that. You might want to check if your assumption of whatresultis, are really holding. Tryconsole.log(result).result === true. It might have turned into boolean.