Hello,
I have a problem with the response text of an ajax request.
I want to use the answer of the php script ("true" or "false") to do different things with a if-condition, but it always takes the false option.
Here is the code.
var hr = new XMLHttpRequest();
...
var data = hr.responseText;
document.getElementById("status").innerHTML = data + " " + data.length + " ";
if (data != "true"){
document.getElementById("status").innerHTML = "yes";
} else {
document.getElementById("status").innerHTML = "no";
}
When using the data.length method, it says the response text has 306 letters (!!).
Just for testing I simplified the php script to the following:
<?php
echo "true";
It's still 303 letters.
Where is the problem? Where do all the letters come from?
Thanks you for all :)