Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 955965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:28:13+00:00 2026-05-16T00:28:13+00:00

I noticed that sometimes(randomly) my Mootools ajax request gets send twice. The second request

  • 0

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();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T00:28:13+00:00Added an answer on May 16, 2026 at 12:28 am

    this seems to do with recycling the old instance of the Request class before it’s “ready” so the old request fires the onSuccess w/o the server closing up the connection where the client loses interest and restarts it, leaving firebug in a waiting state.

    http://www.jsfiddle.net/dimitar/NF2jz/201/

    var r = new Request.HTML({
        url: '/ajax_html_echo/',
        data: {'html': "hello"},
        method: 'post',
        update: 'target_div',
        onSuccess: function(response) {
            (function() {
                go(); // you can reproduce the bug by removing the delay wrap
            }).delay(1000);
        }
    });
    
    var counter = 0;
    
    var go = function() {
        counter++;
        // despite of trying r.cancel(), it does not cancel, 
        // you can set onCancel to test this;
        r.cancel().setOptions({
            data: {html: "attempt " + counter}
        }).send();
    
    };
    
    go();
    

    strictly speaking, if you run off of an anonymous function, you don’t need to be recycling the old instance – or even save it.

    what i would do is something like this (but probably refactored so it can be cancelled):

    var counter = 0;
    (function go() {
        counter++;
        // fresh instance after success / complete:
        new Request.HTML({
            url: '/ajax_html_echo/',
            data: {'html': "hello " + counter},
            method: 'post',
            update: 'target_div',
            onSuccess: function(response) {
                go();
            }
        }).send();
    })();
    

    http://www.jsfiddle.net/dimitar/NF2jz/202/ demoing last code, works fine and in a way that completes and does not interfere with each other.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 481k
  • Answers 481k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Put all the class attributes (e.g. value) up at the… May 16, 2026 at 6:30 am
  • Editorial Team
    Editorial Team added an answer custom_serving_size = forms.ChoiceField( ServingSize.objects.all(), widget=forms.Select(attrs={'class':'ddl'}) ) this has to be… May 16, 2026 at 6:30 am
  • Editorial Team
    Editorial Team added an answer To see the same shade (saturation and brilliance) in different… May 16, 2026 at 6:30 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.