Forum Moderators: open
This may be weird but I can't seem to figure out why responseText is not returning the value my PHP code returns.
So here it is: I have an AJAX enabled script that simply calls a PHP file called test.php. All test.php does is returns a -1.
Javascript:
httpobj.open('get', 'test.php', true);
httpobj.setRequestHeader("Connection", "close");
httpobj.send(null);
httpobj.onreadystatechange = function()
{
if(httpobj.readyState == 4 && httpobj.status == 200)
{
alert(httpobj.responseText);
}
}
<?
echo -1;
?>
When I receive an alert, the value of httpobj.responseText is "0-1". To me, it seems that responseText is holding on to previous values. Does anyone know how I can clear/reset the value so only -1 is returned?
Thanks for any input.
Bobby Pejman
if (x)
echo 0
if (y)
echo -1
It turned out that both conditions x & y were met which made me get an error of 0-1. I ended up doing the following:
if (x)
echo 0;
return;
if (y)
echo -1;
return;
Anyway, I hope this helps someone out although it's a stupid mistake.