So I'm trying to use a single jquery function that uses ajax to talk to a single php page but calls different steps of a process. If the process step completes successfully, it returns the next step so that i can loop through the function again... until I return a 'complete' or 'fail'. I want to time certain steps of the process to account for delayed serverside processing. I'm having trouble using setTimeout inside of the function. I have the following:
function ProcessClient(InProcess){
var dataString = 'inprocess='+InProcess;
if(InProcess=='buildaccount'){dataString+='&vercode='+$('#vercode').val();}
//append current step(status) to client here
$.ajax({
type: "POST",
url: 'ajax/NewClient.php',
data: dataString,
success: function(data){
if(data=='Fail'){
alert(data);
}else if(data=='Complete'){
$('#Progress').append('<li>All done! Click <a href="/manage/">here</a> to head over to your administration page!</li>');
}else{
var Timer = 1000;
if(data=='buildserveraccounts'){
Timer=10000;
}
$(function(){
setTimeout('ProcessClient('+data+')',Timer);
})
}
}
});
}
What am I doing wrong here? As of now... the function isn't even looping.. I've tried a few different things and can never get the timer to work. Oh and I'm open to ideas on better ways to accomplish what I'm trying to... ?