PDA

View Full Version : Dynamic Ajax Content , some quest...



bara
09-16-2006, 07:42 PM
1) Script Title: Dynamic Ajax Content

2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...jaxcontent.htm

3) Describe problem:
1) I want to know , How can I add a loading picture
In this Script.

2) how can I add any effects , for loading pages In this scripts .


thanks.
Bara

jscheuer1
09-17-2006, 05:04 AM
1 ) Find this function in step 1 from the demo page (only the top part is shown as, that is all we will need to change):


function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try { . . .

You can add in some code to display a .gif that portrays loading by adding this code:


function ajaxpage(url, containerid){
document.getElementById(containerid).innerHTML='<table width="100%" height="400"><tr><td valign="middle" align="center"><img src="loading.gif"></td></tr></table>'
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try { . . .

You could use an image like so:

http://www.dynamicdrive.com/dynamicindex4/lightbox2/images/loading.gif

I'm not really sure what you mean by:


2) how can I add any effects , for loading pages In this scripts .

On the demo page, it discusses the use of the loadobjs() function. For more advanced effects that require the added content to be initialized, see:

http://www.dynamicdrive.com/forums/showthread.php?t=13003