Helpful Information
 
 
Category: Ajax and Design
file refresh once when accesed

Hi

I have made a header file and includes it within a template file using AJAX since I couldn't use php's include(); function nor javascript.

What I am wanting to do is get that page that I am calling using AJAX to refresh once everytime you access a page that has that AJAX file calling.
The reason I want this is because if you log in it doesn't update the menu I have for loggedin users to show, instead it still shows that you r not logged. I have to manually refresh the page by accesing it but I don't want that. I want the file to refresh once when accesed through any other file that includes it.

Hope it makes sense.
Here is the ajax code I am using.


<script type="text/javascript">
var rootdomain="http://"+window.location.hostname

function ajaxinclude(url) {
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.open('GET', url, false) //get page synchronously
page_request.send(null)
writecontent(page_request)
}

function writecontent(page_request){
if (window.location.href.indexOf("http")==-1 || page_request.status==200)
document.write(page_request.responseText)
}
</script>

and then the code that calls the page


<script type="text/javascript">
ajaxinclude("/forums/header.php")
</script>

The header.php file above is called from index.php and I want the header.php page to refresh without the user noticing but only once when you access the page.

Thanks for any help.

anyone??? I jus need something to update the file before it displays,

which is the error you get?










privacy (GDPR)