Mootools: Why every flush() in PHP doesnt reflect at user side in mootools events

277 Views Asked by At

i am developing an application in mootools.There is some code which sends request to server using Request class.

req = new Request({
async: false, method: 'post',

someEvent: function(currentChunk) 
{ /* this event is fired everytime when server flushes the output using flush()*/ },

  onSuccess: function(html) { responseProcessor(); },
  onFailure: function() { alert('Page Loading Failed ....!!'); },
});

At the server side, it executes a PHP file where i am flushing output buffer using flush(). but at receiving end, there is onSuccess event which gives me whole responseData in one variable.

Is there any event which is fired after every single time server flushes the output buffer.?

3

There are 3 best solutions below

0
On

The onSuccess callback passes the whole response as parameter. If you make an AJAX call, it returns as response all the stuff that would be rendered on the browser if you accessed that script directly. With mootools Request you can't show the progression of the output (there couldn't be events called after a flush). I don't know if there is a moo plugin that does something like this.

p.s. I know there's a jQuery plugin that could do something for you (Does PHP flush work with jQuerys ajax?)

5
On

there is an progress event documented on the API: http://mootools.net/docs/core/Request/Request

0
On

I checked the JQuery AJAX Http Stream plugin pointed out from the link steweb included in his anwser.

All it does is just a polling. You could extend the MooTools.Core.Request class and create a MooTools.Core.Request.Polling class which would add some options like the polling.

You will need to implement the 'request' event (triggered just before the request is sent) to set up the polling and the complete event to stop it.