I noticed that sometimes(randomly) my Mootools ajax request gets send twice. The second request succeeds right away but the first just keeps waiting indefinitely. I'm not sure if it's a bug in Mootools or something I've done.
This has been verified with firebug in firefox and developer console in chrome. I couldn't verify it in IE, but the symptoms are the same.
I actually managed to take a screenshot of firebug showing the problem: http://janipeltoniemi.net/ajax.png
On the right you see the request loop script I wrote for testing purposes. It just makes a request with a new id after the previous request has completed, so nothing fancy there. The final 2 lines in the console demonstrate the problem I'm having. As you can see, they both have the same response and the same id. The md5 hash is generated using md5(microtime(1))
, so it should be different if these 2 actually were different requests with the same id.
The loop stops at that point because it it doesn't fire the onSuccess event when the last one completes. I'm guessing it would fire it when the other request gets completed, but that hasn't happened yet.
Any ideas what's happening here?
Almost forgot, I'm using Mootools 1.2.4
The code in the image:
r = new Request.HTML();
counter = 0;
//increments the counter and requests hello.php
go = function() {
counter += 1;
//The loop was too fast and producted some side effects when delay was not used
r.get.delay( 10, r, [ 'templates/hello.php', { counter: counter } ] )
}
//Create an endless loop. When the request from go() is finished, call go()
r.addEvent( 'success', go );
//Start the endless loop
go();