StrangerInBeijing
Jul 9th, 2008, 03:46 AM
Hi,
Dont really know how to explain but let me try.
At the moment I got a php script that perform several steps like:
Check if a table exist
Create table if it does not exist
Pull, scrub and insert data from another table to this new table
Loop through the table and process record by record
As it goes through the steps, it will return an error (Like "Could not create table") or continue to the next step, until all done, then return noting (So in the JavaScript I know it was successful)
I run this script via Ajax the normal way, waiting for the readyState to be 4 and the status to be 200 and then act.
function processed() {
if (request.readyState == 4) {
if (request.status == 200) {
var _indicator = document.getElementById('_indicator'); // progress bar
var _message = document.getElementById('_message');
_indicator.style.display = 'none';
_result = request.responseText;
if(_result=="") {
_message.innerHTML = "Ip2Location data processed successfully!";
} else {
_message.innerHtml = _result;
var _form = document.getElementById('_form');
_form.style.display = 'block';
}
}
}
}
All of this works fine, but I was wondering if there is a way to return a "current status" from the php script to ajax which cna then change some "Current Status is .... whatever" on the calling page?
It's not a big issue, just curious about this
Dont really know how to explain but let me try.
At the moment I got a php script that perform several steps like:
Check if a table exist
Create table if it does not exist
Pull, scrub and insert data from another table to this new table
Loop through the table and process record by record
As it goes through the steps, it will return an error (Like "Could not create table") or continue to the next step, until all done, then return noting (So in the JavaScript I know it was successful)
I run this script via Ajax the normal way, waiting for the readyState to be 4 and the status to be 200 and then act.
function processed() {
if (request.readyState == 4) {
if (request.status == 200) {
var _indicator = document.getElementById('_indicator'); // progress bar
var _message = document.getElementById('_message');
_indicator.style.display = 'none';
_result = request.responseText;
if(_result=="") {
_message.innerHTML = "Ip2Location data processed successfully!";
} else {
_message.innerHtml = _result;
var _form = document.getElementById('_form');
_form.style.display = 'block';
}
}
}
}
All of this works fine, but I was wondering if there is a way to return a "current status" from the php script to ajax which cna then change some "Current Status is .... whatever" on the calling page?
It's not a big issue, just curious about this