I have a page that loads in “get-results.php” which loads the results into a div. This works great. However, I also need to grab a variable from the php file that is being loaded, so that I can re-include it in the .load() url, this way I can have the php file have the previous result for comparison.
$(".results").load("get-results.php" + "?userClicked=" + var1 + var2 + "&prevresult=" + theResults);
In the “get-results.php” file, I have set
var theResults = "<?php echo $result; ?>";
Is there a way for me to access “var theResults” from the page that is loading it (outer page, not inner)? How can I get the Var from the file and put it into a Var in the outer file? Any pointers would be great thanks.
obviously you have to wait the load is complete to get the new value for theresults.
otherwise, you can use
$.getwhich seems more appropriate here :edit : if you are indeed sending more than this php var, you should send back a json (with your variables to be sent in an array then you
echo json_encode($arrayofvar)then in the js you’ll retrieve a json object of your var in the getJSOn callback