I have some jquery ajax call that returns a simple string.
The interpretation of the return string is working in Firefox and IE (class is set to ok), but not in Chrome (class is set to wrong)?
The php in myurl simply returns a string with a numerical value. In Chrome, an alert(type of result.responseText); also gives me a string and debugging suggest that the value is indeed 100. But Chrome for some reason does not dive into the if statement.
Any ideas?
$.ajax({
url : 'myurl',
data:{o:1},
dataType:"text",
complete : function (result) {
if (result.responseText==100){
$("#mydiv").addClass("ok");
}
else {
$("#mydiv").addClass("wrong");
}
}
});
It appeared that myurl returned a string with an additional BOM (“100” was returned, not “100”). Setting the documument encoding in UTF-without DOM fixed it. This helped: How to avoid echoing character 65279 in php? (This question also relates to Javascript xmlhttp.responseText (ajax))