I have an HTML form which uses selections from a drop-down list to populate a mySQL table, but with jQuery / AJAX calling an external php file to update the display of entered lines below the original form.
The purpose of the form is an order entry system, and as such works: select an item, see it added to the list. The problem that I have is that as well as having the entered items displayed, I want to show the total order value updating. I thought that I would be able to use a PHP session variable, but that doesn't seem to work unless the original page is refreshed.
Therefore, my question is: is there a way to get session variables (or any other sort of variable) back from my external php file as well as the HTML that I am appending to the displayed page?
If it helps this is the code that I'm using to call the external php when adding a new row:
$.ajax({
type: "POST",
url: "ajaxInsertOrderLine.php",
data: dataString,
cache: false,
success: function(html){
$("#orderItems").append(html);
document.getElementById('inputStockNo').value='';
document.getElementById('qty').value='';
document.getElementById('totalAmount').value="<?php echo $_SESSION["totalValue"]; ?>";
}});
where "ajaxInsertOrderLine.php" is the external file, 'inputStockNo' and 'qty' are two form variables being sent to the script and zeroed after a successful insertion.