0

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.

BLenau
  • 95
  • 1
  • 4
  • 12
  • possible duplicate of [JQuery ajax progress via xhr](http://stackoverflow.com/questions/22502943/jquery-ajax-progress-via-xhr) – sodawillow Jan 08 '15 at 22:38

1 Answers1

0

You would have to open a socket connection. I'm guessing if you are asking this question you don't know what a socket connection is. But you can google a good socket tutorial for PHP and I'm sure you will come up with something.

kayleighsdaddy
  • 670
  • 5
  • 15