Loading image to avoid page load

Discussion in 'PHP' started by khan11, Sep 25, 2007.

  1. #1
    Hi guys,


    i have used $_GET along with include to connect my pages together..
    For example:
    Buttons:
    HOME
    SERVICES
    BLAH BLAH

    I used
    if($_GET['home']) {
    include("home.php")'
    }elseif.....



    what i want is , when we click one button, it takes some time to include that file on page, so, loading image comes mean time...

    when the page is fully loaded, that image should go off and the stuff can be seen.

    I hope you get it..


    any help?
     
    khan11, Sep 25, 2007 IP
  2. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You would have to use Javascript to achieve it, possibly look into ajax.
     
    matthewrobertbell, Sep 25, 2007 IP
  3. khan11

    khan11 Active Member

    Messages:
    615
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    58
    #3
    well, i want to use ajax loader script with my php includes..

    <HEAD>
    
    <style type="text/css">
    <!--
    #contentLYR {
      position:absolute;
      width:200px;
      height:115px;
      z-index:1;
      left: 200px;
      top: 200px;
    }
    -->
    </style>
    
    <script type="text/javascript">
    <!-- Begin
    /* This script and many more are available free online at
    The JavaScript Source!! http://javascript.internet.com
    Created by: Eddie Traversa (2005) :: http://dhtmlnirvana.com/ */
    
    function ajaxLoader(url,id) {
      if (document.getElementById) {
        var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
      }
      if (x) {
        x.onreadystatechange = function() {
          if (x.readyState == 4 && x.status == 200) {
            el = document.getElementById(id);
            el.innerHTML = x.responseText;
          }
        }
        x.open("GET", url, true);
        x.send(null);
      }
    }
    //-->
    </script>
    </HEAD>
    
    <!-- STEP TWO: Insert the onLoad event handler into your BODY tag  -->
    
    <BODY onLoad="ajaxLoader('demo.xml','contentLYR')">
    
    <!-- STEP THREE: Copy this code into the BODY of your HTML document  -->
    
    <div id="contentLYR">
    </div>
    
    Code (markup):
    I have this script, i tried to insert on my page, but nothing happens, tell me what do i need to do with it to start working with my includes or page loads.
     
    khan11, Sep 25, 2007 IP