mootools - duplicate ajax requests at random -


I have noticed that sometimes my random acne request (randomly) sends the request twice but the second request is immediately successful but First, only waiting for indefinitely. I'm not sure whether it's a bug in Mootools or something I've done.

It has been verified in Firefox and Developer Console in Chrome. I could not verify it in IE, but the symptoms are the same.

I have been able to really take a screenshot of the firebug showing the problem:

On the right you see the request loop script I wrote for test purposes. After only makes a request with a new id, so there is nothing fancy. The last 2 lines in the console show the problem showing me as you can see, both have the same response and the same ID is MD5 hash md5 (microgram (1)) Using it, so it should be different if these 2 were actually different requests with the same ID.

The loop stops at that point because it does not fire the onSuccess event when the previous one is complete. I'm guessing that when this second request is completed, it will set the fire, but So far it has not happened.

Any thoughts that are happening here?

Almost forgot, I'm using Mootools 1.2.4

code in the image:

  r = new request HTML (); Counter = 0; // increment and request hello.php go = function () {counter + = 1; // loop was very fast and some side effects were produced when using delay r.get.delay (10, r, ['templates / hello.php', {counter: counter}])} // an endless loop. When the request () ends, call () r.addEvent ('success', go); // Start endless loop ();  

This "prepares" the old example of the request class with recycling before it is ready. "Therefore, the old request is successfully promised that the server closes the connection where the client loses interest and restarts it, leaving a firebug in the waiting position.

  var r = new request.HTML ({url: '/ ajax_html_echo /', data: {'html': "hello"}, method: 'post ', Update:' target_div ', succeed: function (response) {(function () {Go (); // You can reproduce the bug by removing the delay sheet}). Delay (1000);}} ); Var counter = 0; Var go = function () {counter ++; // r.cancel (), despite trying, does not cancel it, // you can cancel it to set up; R.cancel () SetOptions ({Data: {html: "attempt" + counter}}). Send (); }; go();  

Strictly speaking, if you run away from an anonymous function, then you do not have to recycling the old example - or even to save it.

What I will do is something like this (but it has probably been re-applied so that it can be canceled):

  var counter = 0; After success / full: new request HTML ({url: '/ ajax_html_echo /', data: {'html': "hello" + counter}, method: 'post', update: 'target_div', succeed: function (feedback) {go ();} }). Send ();}) ();  

To demo the previous code, works fine and works in a way that does not interfere with each other.


Comments