Results 1 to 4 of 4

Thread: how to know when the ajax scripts were fully loaded?

  1. #1
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to know when the ajax scripts were fully loaded?

    Hello,

    im using the script from http://www.dynamicdrive.com/dynamici...jaxcontent.htm

    and i cant figure how to know if my script (its below) is loaded...
    i started using javascripts only a week ago, and im not so good at it, so please help me out!

    Code:
    function loadit() {
    ajaxpage('test1.htm', 'contentarea1');
    ajaxpage('test2.htm', 'contentarea2)';
    ajaxpage('test3.htm', 'contentarea3');
    }

    so ho dow i know when "loadit" function is finished the work?

    its the last component to my search engine

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    What do you mean by loaded? Like if there are images on the imported pages, when they are loaded? Or just the HTML code, when it is loaded?

    Also, why do you need to know? I ask this because I've found that it is often better - say you need to do something with the loaded content, to have some action in relation to the loaded content do this. That way it can only happen if the loaded content is there.

    Failing that, one can poll. This involves running a repeating function at the beginning of import that checks for something unique on the imported content (usually something at the end, or it could be onload events of images), when the function finds the thing or receives information from an image's load event, it stops and sets a flag that lets other code know the content is ready.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i just need to know when this script is finished loaded, i mean script "loadit"

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by mysterbx View Post
    i just need to know when this script is finished loaded, i mean script "loadit"
    I don't think you really mean that. But if you do, it's easy:

    Code:
    function loadit() {
    ajaxpage('test1.htm', 'contentarea1');
    ajaxpage('test2.htm', 'contentarea2)';
    ajaxpage('test3.htm', 'contentarea3');
    }
    alert('loadit loaded!');
    I think you want to know when its work, or at least some aspect of its work has been completed. That's a whole different story which I addressed (to a degree) in my previous post.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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