Bear with me, and I will try and explain the issue that I am sure others have faced but can find nothing on the web that points to a work around.
Page 1 (A PHP page with Ajax) Purpose to collect data and the redirect to the next page to display the updating page, i.e.
window.location.replace("Updating.php"); <-- This is Page 2
Page 2 (A PHP page with minor html and PHP scripts that updates the server databases) The problem is that this page will not fully render until after the PHP scripts have completed. Because the process can take say 10 or so seconds the user is left wondering what is happening and essentially the Updating Page (Page 2) does not render until it the scripts are finished which of course defeats the purpose.
Question
Is there a similar function to the javascript onload <body onload="myFunction()">
that can render the page before the scripts begin running. I don't think there is but would appreciate and insight how I might overcome this problem.
Thanks
EDIT TO ADD REQUESTED AJAX CODE
function handleDataCallback(result) {
var json = eval('(' + result + ')');
if (json['msg'] != "") {
// alert(json['dirID']);
processUpload(json['dirID']);
}
};
/*
* This is called when uploadFile.js is finished.
* We many need to add an AJAX WaitforID here in case the processUpload takes too long.
*/
function processUpload(data){
var dir_name = data;
$.ajax({
url: 'processUpload.php',
type: 'POST',
data: {'folderKey' : dir_name },
success: function(data) {
'<%Session["dir_id"] = "'+ dir_name + '"; %>';
//Takes us back to the index file with the directory
// window.location.replace("../../index.php?dir_id="+dir_name);
window.location.replace("Updating.php");
}
});
};
/*
* Obtains the dirID
*/
function waitForDataID (handleDataCallback) {
$.ajax({
type: "GET",
url: "extractArchives.php",
async: true,
cache : false,
timeout: 10000, // sets timeout to 30 seconds
success : handleDataCallback,
erorr : function (XMLHttpRequest,textStatus, erorrThrown) {
alert("erorr :" + textStatus + "(" + erorrThrown + ")");
}
});
};