I am currently working on a project that I would like to send an ajax request that will initiate a database synchronization between a local database and a remote database using PHP.
I was wondering if it is possible to send progress data from the PHP ajax handling script back to the jQuery ajax call to display the synchronization progress to the user.
Here is an example of what I mean:
jQuery.ajax({
url: ajaxUrl,
type: post,
dataType: 'json'
}).done(function(data) {
// Check for returned progress data
if (data.complete) {
// Display "Synchronization complete!" or something similair
} else {
// Display progress data such as "Inventory data synchronized..."
}
});
I'm not even sure if something like this is possible, but I was hoping I could get some help on it. I did look into xhr
briefly, but I was unsure if I could accomplish my goals with it or not.
I know that I could accomplish this with cascading ajax calls, but I would prefer to not need to do it that way as it would be quite a bit more inefficient.