Sending variables from javasrcipt/ajax

what I am trying to do is send $id via a javascript/ajax method
At present $id is blank or not being sent to the php page.

here is the php

<?php 
$id;
$RETURN = "<div style='display:block; width:200px; height:300px; background:white;'>".$id."</DIV>";
echo $RETURN;
?>

this is the function I have been trying.
I have made the variable static for now. but this will be (parameters)

f

unction getAjaxRequest(parameters)
    {
    
    
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
          tabselector.expandit(2)
          document.getElementById("TAB3").innerHTML= xmlHttp.responseText;
      //document.myForm.time.value=xmlHttp.responseText;
      }
    }
    
  xmlHttp.open("GET","php/selection-details.php?id=12" ,true);
  xmlHttp.send(null);
  
  
}

If anyone can share their wisdom I would much appriciate it.

I´m not sure I understand your problem but the following code might be of some help to you otherwise please specify your problem.

Just click the div and the AJAX request will fire.


 <?php 
 // 
$id = 1234;
$RETURN = "<div id='theDiv' style='border:1px solid red; display:block; width:200px; height:300px; background:white;' onclick='getAjaxRequest(".$id.")'>".$id."</div>";
echo $RETURN."<br/>
\r";
?>
<script>
	function getAjaxRequest(parameters){
		var xmlHttp;
		try{
			// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
		}
		catch (e){
			// Internet Explorer
			try{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e){
				try{
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e){
					alert("Your browser does not support AJAX!");
					return false;
				}
			}
		}
		xmlHttp.onreadystatechange=function(){
			if(xmlHttp.readyState==4){
				//tabselector.expandit(2)
				document.getElementById("TAB3").innerHTML= xmlHttp.responseText;
				//document.myForm.time.value=xmlHttp.responseText;
			}
		}
		theId = document.getElementById("theDiv").innerHTML;
		xmlHttp.open("GET","selection-details.php?id="+theId ,true);
		xmlHttp.send(null);
	}
</script>
<br/>
<div style="border:1px solid red;" id="TAB3">some text</div>

and the selection-details.php…


<?php
	echo 'id = '.$_GET['id'];
?>

yeh it was the global vars on the server

$id = $_GET[“id”];

hanks for the respose