A PHP page contains a variable $hash
and has a button. The button's click event is handled by jQuery. I want jQuery to do an AJAX call as follows:
$.post("testupdate.php", {hash:"<?php echo $hash; ?>"} , function(data) {
$("#body").html(data);
});
However, the PHP code <?php echo $hash; ?>
inserted inside the AJAX call isn't working. How can I make it work please? Thanks.
Update: I made it work by inserting a script element in the html page which is processed before the jQuery call:
<script> var hash = "<?php echo $hash; ?>"; </script>
And then did the following in the jQuery function call:
$.post("testupdate.php", {hashpost:hash} , function(data) {
$("#body").html(data);
});