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 to the CF scene
    Join Date
    Sep 2007
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post

    Ajax loader using php include Possible?

    Hello!

    I have a question. Is it possible to use an ajax loader to load a php page that displays a repeating table of information?

    The reason I want to do this is because the php page takes forever to load and it doesn't display anything till everything is done by the server.

    So I am wondering how to create a script that displays a loader image while the php page is being executed and when it is then the image disappears and the php page is displayed in its place.

    I am thinking using <div> for all of it but I don't know where to go from there.

    I tried looking for a script on google but to no avail.

    Anyone have any ideas?

    Thanks!

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Add a div to the page. On window.onload fire off an Ajax call to fecth the PHP page that generates the table. When the request returns set the innerHTML of the table with the responseText.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New to the CF scene
    Join Date
    Sep 2007
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post
    This is what I put and it works great! This is the script part.
    Code:
    <script type="text/javascript">
    function ajaxFunction()
      {
      var xmlHttp;
      try
        {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
        }
      catch (e)
        {
        // Internet Explorer
        try
          {
          xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
          }
        catch (e)
          {
          try
            {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
          catch (e)
            {
            alert("Your browser does not support AJAX!");
            return false;
            }
          }
        }
        xmlHttp.onreadystatechange=function()
          {
          if(xmlHttp.readyState==4)
            {
            document.getElementById("content").innerHTML=xmlHttp.responseText;
            }
          }
        xmlHttp.open("GET","list.php",true);
        xmlHttp.send(null);
      }
          </script>
    Here is the HTML part.
    Code:
    <div id="content"> 
      <br/>
      <br/>
      <br/>
      <h1>Loading ... Please wait </h1>
      <br/>
      <br/>
      <img src="../ajax-loader.gif" />
        </div>

  • Users who have thanked coolbeansdude51 for this post:

    xeyel (10-30-2007)


  •  

    Posting Permissions

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