my problem is: I have to pass a variable from a.php to b.php with an ajax call that take the variable 'numitems' from a.php and pass it to b.php...
My code is below but when I try to retrieve 'numitems' in b.php I receive this message:
Notice: Undefined index: numitems in b.php on line 19
stringaPost();
xmlHttp.open('POST', "b.php", true);
xmlHttp.onreadystatechange = function() {
if(xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
data: {numitems : <?php $numitems;?> }
document.getElementById("primaryContent").innerHTML=xmlHttp.responseText;
}
}
};
Instead in b.php I have:
$numitems = $_POST['numitems'];
The problem is probably in the line with data: {numitems : <?php $numitems;?>
but I'm not sure and I can't figure out the root of the problem.
<?php echo $numitems;?>or<?=$numitems;?>, but you're probably executing the script way before $numitems is being set.b.phpdon't calla.phpdirectly to get those variables ?