little help pls... returning variable

Discussion in 'PHP' started by bartolay13, Nov 18, 2007.

  1. #1
    hi there,

    i have a little problem in handling variable.. im very confused, where is my variable. its missing,thus, how can i catch it.

    ie . situation:
    i use AJAX

    1.php (client side page)
    -calls function in 2.js page


    2.js (javascript xml page)
    -here is the function

    
    var XMLHttpRequestObject;
    
    function getHttpRequestObject()
    {
    	if(window.XMLHttpRequest)
    	{
    		XMLHttpRequestObject = new XMLHttpRequest();
    	}
    	else if(window.ActiveXObject)
    	{
    		XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	return XMLHttpRequestObject;
    }
    // str = admin_menu; str2 = subContent; divId = destination div
    function getData(str,str2,divId)
    {
    	XMLHttpRequestObject = getHttpRequestObject();
    	if(XMLHttpRequestObject)
    	{
    		var obj = document.getElementById(divId);
    		a = str;
    		b = str2;
    		
    		var url = "includes.php?admin_menu="+a+"&subContent="+b;
    		
    		XMLHttpRequestObject.onreadystatechange = function()
    		{
    			if(XMLHttpRequestObject.readyState==4 && XMLHttpRequestObject.status == 200)
    			{
    				obj.innerHTML = XMLHttpRequestObject.responseText;
    			}
    		}
    		XMLHttpRequestObject.open("GET",url,true);
    		XMLHttpRequestObject.send(null);
    	}
    	else
    	{
    		alert("Your browser is not supported.");
    	}
    }
    
    PHP:
    just a simple ajax, sends the variable from the html page(1.php) to the server side (3.php)

    3.php (server side script)
    catches the variable and echo it to the div container in the html page (1.php)
    
    echo $_GET['admin_menu'] . " " . $_GET['subContent'];
    
    PHP:
    my question is how can a server side page throw a variable to the client side page, it is because i have a condition statement in the client side page.? and the condition needs to be satisfy.

    if possible i want the variable in php format($_GET,$_POST)

    please help
    thanks in advance
     
    bartolay13, Nov 18, 2007 IP
  2. rustem

    rustem Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It is hard to understand what you want. What variable are you missing?
     
    rustem, Nov 19, 2007 IP
  3. aRo`

    aRo` Peon

    Messages:
    141
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    why do you use 3 pages ?
     
    aRo`, Nov 19, 2007 IP