My Ajax application was working fine, until I implemented an if statement in the PHP script... then like a contagious disease it seems that if I do anything to the data in PHP it returns nothing back to the Javascript layer.
All I can do is echo the data back...
For instance the query string I'm sending to the PHP reads...
index.back3.php?form=login&json={"email":"[email protected]","password":"asdasdfas"}
and I know its getting there because in the simplest debugging PHP file (index.back3.php) that I created all I have is a simple echo statement... and it never fails to send back the data to the Javascript file.
when index.back3.php reads
<?php echo $_GET[json]; ?>
the alert that I have triggering off in the javascript reliably spits out the json string.
also when it reads
<?php echo $_GET[form]; ?>
when I get any more complicated than that nothing comes back to the javascript. Even a simple concatenation...
<?php echo ($_GET[form] . $_GET[json]); ?>
...returns nothing!
A simple if...else statement also returns nothing.
<?php
if(!isset($_GET[form]) {
echo "no!";
} else {
echo "yes!";
}
?>
And this important operation also...
<?php
$array = json_decode($GET[json], true);
var_dump($array);
?>
returns nothing.
OK... so just to make sure everything is above board here is my Ajax output function in the Javascript layer.
function responseAjax() {
if (myRequest.readyState == 4) {
if(myRequest.status == 200) {
var foo = myRequest.responseText;
alert(foo);
} else {
alert("An error has occured: " + myRequest.statusText);
}
}
}
Can someone please explain what's going on? I'm truly stumped.