i have this php file (stripped down to the essential part)
getBoundaries.php
<?php
$t = "";
//$t = "t";
Header("Content-type: text/plain; charset=utf-8");
echo ($t);
?>
and this javascript ajax call:
function anyname(){
var xhttp;
var query = "tid=1&pid=1";
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
var temp = xhttp.responseText;
if (temp == ""){
console.log("ein leerer string");
}
else{
for (i = 0; i < temp.length; i++){
console.log(temp.charCodeAt(i));
}
}
}
}
xhttp.open("POST", "getBoundaries.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send(query);
}
The output of console.log
with $t=""
were 32, 10, 32.
The output of console.log
with $t="t"
were 116, 32, 10, 32.
So, my question is: WHY isn't an empty string returned as responseText? Where are these additional 3 characters added? My assumption: the echo
php-command adds those three chars.
Any suggestions?