Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.
    Code:
    <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
    PHP Code:
    <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.

  • #2
    New Coder
    Join Date
    Jan 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyone??? I jus need something to update the file before it displays,

  • #3
    New Coder
    Join Date
    Mar 2007
    Location
    italy
    Posts
    94
    Thanks
    1
    Thanked 1 Time in 1 Post
    which is the error you get?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •