View Full Version : how to know when the ajax scripts were fully loaded?
mysterbx
08-01-2008, 05:35 PM
Hello,
im using the script from http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.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!
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
jscheuer1
08-01-2008, 06:57 PM
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.
mysterbx
08-01-2008, 09:12 PM
i just need to know when this script is finished loaded, i mean script "loadit"
jscheuer1
08-02-2008, 03:59 PM
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:
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.