i am looking for a way to directy access the variables of the page that loaded another page inside a div in it using ajax. i know i can do it using some kind of a get string pass it to the Javascript and open the son page with it and retrieve the variables using get normal GET function, i am looking for a better solution. i have this parent page:
<body onLoad="control_post_data(<?php
echo true;
//echo isset($_COOKIE['username']); // allow after login is done
?>)">
<div id="publish_page">
</div>
and this is the script:
function control_post_data(bool){
var div = document.getElementById("publish_page");
var xmlhttp = createXmlHttpRequestObject();
if(bool){
//user is registered presend post page
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var responseText = xmlhttp.responseText;
div.innerHTML = responseText;
//Use the response text to add the extra row
}
}
xmlhttp.open("GET","sub_published.php",true);
xmlhttp.send();
} else {
//present log in/register page
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var responseText = xmlhttp.responseText;
div.innerHTML = responseText;
//Use the response text to add the extra row
}
}
xmlhttp.open("GET","login.php",true);
xmlhttp.send();
}
}
i am trying to acces the parent page variables in the sub_published.php page.