How can I pass the value of a php variable to an AJAX request? I'm using sessions here, started in another php file (header.php). The variable is "$_SESSION['name']", and I want to pass as a parameter instead of "XXX" (the function is called by a button).
<?php include("header.php"); ?>
<script>
function sendFunc()
{
var message = document.getElementById('msg_text').value;
new Ajax.Request("chat_room_insert.php",
{
method: "post",
parameters: {id: 0, name: "XXX", msg_text: message},
onSuccess: function() {},
onFailure: function() { alert("failure"); },
onException: function() { alert("exception"); }
});
}
</script>