This project is archived and is in readonly mode.

#667 ✓duplicate

Request called from within its onComplete callback looses its completion

Reported by akc42 | May 12th, 2009 @ 03:38 PM | in 1.2.3

I originally raised this ticket about a month ago - but lack of knowledge about how this system worked means I posted it incorrectly in mootools.more rather than the core.

It is also raised in ticket #614, but again I incorrectly assigned that to 1.3.0 and (I presume) as a result no-one has done anything with it.

I would like to get it fixed - I have a high speed game (on-line air hockey) where this problem causes issues, so I have been using a fork of mootools, with the patch below, to make it work. This means it has been extensively tested.

If a Request is called again from its onComplete function (or the related ones) the second request fails to complete. The reason is the relative ordering of this statement

this.xhr.onreadystatechange = $empty;

This is currently called after the onComplete callback - such that it effectively squishes the second request commplete state change.

the following patch corrects the problem

--- a/mootools-1.2.1-core-nc.js +++ b/mootools-1.2.1-core-nc.js @@ -3659,6 +3659,7 @@ var Request = new Class({

                    this.status = this.xhr.status;

  •         this.xhr.onreadystatechange = $empty;
            if (, this.status)){
                    this.response = {text: this.xhr.responseText, xml: this.xhr.responseXML};
                    this.success(this.response.text, this.response.xml);
    @@ -3666,7 +3667,6 @@ var Request = new Class({
                    this.response = {text: null, xml: null};
  •         this.xhr.onreadystatechange = $empty;
    isSuccess: function(){

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket