I'm trying to compare the result from from ajax call with a string. My result is returning the correct result but i can't get the if statement to compare this with my string, any ideas?
$.ajax({
type: "POST",
url: "sessionCheck.php",
data: {id:mwdata},
success: function(html) {
if (html == "open"){
alert ("yes it's open");
}else if(html == "closed"){
alert ("no it's closed");
}
}
});
console.log(html)?htmlcontains whitespace you aren't accounting for. Use JSON instead of invalid HTML.console.log(html.length);and see the length is correctelse { alert("it is not close neither open"); }