Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wait for PHP scripts to process before moving on 1

Status
Not open for further replies.
Apr 27, 2006
126
GB
OK, I'll try explain what I need/would like help with without confusing myself and any innocent bystanders

index.php contains various divs with includes to other php files which gather various bits of information.

one of these divs (called "link")includes a makelink.php which (for the sake of keeping this simple) creates a link of the <a href="Javascript: Dostuff(Variable)"></a> variety

Now, that javascript is along the lines of:
Code:
function DoStuff(Variable)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
        alert ("Browser does not support HTTP Request");
        return;
}
var url="/DoSomething.php?Variable="+Variable+";
xmlHttp.readystate
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
setTimeout("window.location = '/index.php'",200);
}

the "DoSomething.php" does a few checks, updates a mysql db and generally has a good old time. The concern I have is the timeout.. it's hardly a safe way of ensuring nobody gets the page refresh before the server has finished processing.

Now, ideally I'd want the process to be like this:

1. xmlHttp.open("GET",url,true)
2. waits until the above has finished processing
3. ajaxpage('/makelink.php', 'link')
4. ajaxpage('/someother.php', 'anotherdiv')

to have the whole process a nice, seamless process with no full page refreshes and for everything to be guaranteed up-to-date on their screen by the time everything reloads

Is this possible? or am I just setting myself up for disappointment?

Any help will be appreciated.

Cheers

________
clueless
 
this seems to be an ajax question and best asked in the general ajax forum.

but the answer is, anyway, to make each ajax request synchronous rather than asynchronous. so change that TRUE to FALSE....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top