Jump to content

AJAXing a php file after some time...


Xajel

Recommended Posts

I'm making a website but to be clear and make it sure, I'll just make some points

 

1- 4 links, each AJAX seperate php file ( lets say 01.php, 02.php, 03.php & 04.php ).

2- clicking any link will start AJAXing the file. but there must be a delay of at minimum of 2 sec. from clicking the link to show the file.

3- in that delay, a flash animation will show up as waiting animation.

4- these four PHP files MUST be downloaded each time the user click the link, usualy the browser will get the cached page, but no I want it to reload the file directly from the server, no HTML meta here as these files only has a table showing some info...

 

so to make it as steps...

 

1- the user click one of these 4 links...

2- a setTimeout will start @ 2000 millisec + .innerHTML will load the flash animation. + the php will start loading ===> all these in the same time

3- after the 2000 millisec. if the php file is loaded then it will be showed in the page, or it will continue to play the flash animation. till the php file is completly loaded.

 

+ I'll make an update to the flash file later, so if the file is loaded, the javascript must send a variable to the flash ( just a small js function, I'll handle the rest )

 

I already made the AJAX works, but whenever I start using the setTimeout function I got an error and the script wont work at all !!

 

// function loaded when clicking the links...
function xData(xGet){
document.getElementById('xAjax').innerHTML = 'FLASH HTML here';
onTimeout("xLoad(xGet);", 2000);
}

// xLoad is the regular AJAX function...
function xLoad(xGet) {
if (xGet=='xmobiles') {
	http.open('get', 'x-newmobiles.php');
}else if(xGet=='xreviews') {
	http.open('get', 'x-newreviews.php');
}else if(xGet=='xtopics') {
	http.open('get', 'x-newtopics.php');
}else{
	http.open('get', 'x-newmarket.php');
}
http.onreadystatechange = handleInfo;
http.send(null);
}

 

when I load the xLoad function directly when clicking the links, every thing works perfectly but without the 2000 millisec delay...

Link to comment
https://forums.phpfreaks.com/topic/90037-ajaxing-a-php-file-after-some-time/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.