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 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2008
    Posts
    93
    Thanks
    30
    Thanked 0 Times in 0 Posts

    Loading a file without using AJAX

    Hello,
    Does anybody know of a method to load a text file into an HTML document without using AJAX? I am tryng to load some tables that I use at work in several different web pages but with the AJAX asynchronous mode, the scripts that I am using start running before the tables are ready.

    Thanks,
    Don

  • #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    The dynamic loading should be done onload, not inline. But, to your question, use a server side script (say, in PHP) to pull your data and drop it into the table as it's built.

  • Users who have thanked tomws for this post:

    dragon6158 (06-24-2008)

  • #3
    Regular Coder
    Join Date
    Sep 2007
    Location
    AZ, USA
    Posts
    685
    Thanks
    6
    Thanked 46 Times in 46 Posts
    Yes, as tomws says, if you make the code execute onload the table should be ready.

  • Users who have thanked binaryWeapon for this post:

    dragon6158 (06-24-2008)

  • #4
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    just in case it helps, you can use an event listener to watch for the page to be loaded


    Code:
    <script type="text/javascript" charset="utf-8">
    	Event.observe(window,'load',function(){your function goes here});
    	</script>
    so once the page is loaded then it could call your ajax or whatever you please.

    if you want it to wait a bit after loading before doing whatever it will do you could use the setTimeout method

    Code:
    <script type="text/javascript" charset="utf-8">
    	Event.observe(window,'load',function(){
                      window.setTimeout("your function goes here",100);
    });
    	</script>

  • Users who have thanked ohgod for this post:

    dragon6158 (06-24-2008)

  • #5
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    You can also set a hidden iframe's source to a text file and read from it if it is imperative that the data be processed after the page is loaded due to user interaction.
    Helping to build a bigger box. - Adam Matthews


  •  

    Posting Permissions

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