javascript - Unable to perform any PHP operations in an Ajax application -
my ajax application working fine, until implemented if statement in php script... contagious disease seems if data in php returns nothing javascript layer.
all can echo data back...
for instance query string i'm sending php reads...
index.back3.php?form=login&json={"email":"mo@maurice-campobasso.com","password":"asdasdfas"}
and know getting there because in simplest debugging php file (index.back3.php) created have simple echo statement... , never fails send data javascript file.
when index.back3.php reads
<?php echo $_get[json]; ?>
the alert have triggering off in javascript reliably spits out json string.
also when reads
<?php echo $_get[form]; ?>
when more complicated nothing comes javascript. simple concatenation...
<?php echo ($_get[form] . $_get[json]); ?>
...returns nothing!
a simple if...else statement returns nothing.
<?php if(!isset($_get[form]) { echo "no!"; } else { echo "yes!"; } ?>
and important operation also...
<?php $array = json_decode($get[json], true); var_dump($array); ?>
returns nothing.
ok... make sure above board here ajax output function in 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 please explain what's going on? i'm stumped.
if(!isset($_get[form]) { echo "no!"; } else { echo "yes!"; }
?>
you missing closing parenthesis in if statement. , said few times before, put quotes around array keys.
while in development, should maybe turn on error_reporting e_all. helps find out small error might be.
Comments
Post a Comment