damik
12-09-2008, 06:14 PM
Is there a “best practice” in passing variables from Ajax to a PHP file?
Ex:
index.php
<?php
$constant = “This is my global constant I want accessible in all files.”;
?>
// ajax script
url = "extfile.php";
req.open("GET", url, true);
exitfile.php
<?php
echo $constant;
?>
This will work using sessions or if I pass $constant through the URL, but as I’m new to Ajax I’m wondering if there’s a better, more appropriate way of handling this. Thanks.
Ex:
index.php
<?php
$constant = “This is my global constant I want accessible in all files.”;
?>
// ajax script
url = "extfile.php";
req.open("GET", url, true);
exitfile.php
<?php
echo $constant;
?>
This will work using sessions or if I pass $constant through the URL, but as I’m new to Ajax I’m wondering if there’s a better, more appropriate way of handling this. Thanks.