I've been racking my brain for a few hours and can't figure out why a string comparison won't work. In the following code, I do a xmlhttp call and get a response text. The PHP file that I get a call IS returning the proper response string "NOAD"
, and NOAD
is being displayed when appropriate in my testing. However, when the call is returned NOAD
I want to identify it, however for some reason within the call below xmlhttp.responseText == comparisonText
its NOT properly comparing the two. Why does xmlhttp.responseText
printout NOAD but I can't use it within the comparator?
function loadXMLAdImage1Doc(currentScenarioTime)
{
var returnText = "Not Here";
var comparisonText = "NOAD";
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
if (xmlhttp.responseText == comparisonText)
{
document.getElementById("AJAXTEST").innerHTML =returnText;
} else {
document.getElementById("AJAXTEST").innerHTML =xmlhttp.responseText;
}
}
}