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 8919633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:04:55+00:00 2026-06-15T06:04:55+00:00

Usecase: When an anchor tag is clicked, send the information to server that this

  • 0

Usecase: When an anchor tag is clicked, send the information to server that this item has been clicked. Here you can find this fiddle: http://jsfiddle.net/nXYQP/5/

Now, When i do some fast clicks on anchor tag, I can see the handler is getting called equal to the number of times i have clicked. But the number of AJAX requests sent from the handler is quite less in number.

Use Chrome Developer Tool to check the number of requests sent.
Press F12 to open developer tool and navigate to Network tab and then click on anchor tag to see the number of requests it sent.

I am unable to reason this behavior. Please put some light on it.

Here is my code:

<a id="inc" href="http://www.google.com"> Click me </a>
<div id="container"> Click count will be updated here </div>

Javascript code:

var text = "Click no:-";
var counter = 0;

$("#inc").click(function() {
     var new_request = new XMLHttpRequest();                      
     var new_serverURL = "http://www.google.com";
     new_request.open('GET',new_serverURL,true);
     new_request.send(null);

    $("#container").html("<p>" + text + " " + counter + "</p>");
    counter++;
});​

​

  • 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-06-15T06:04:56+00:00Added an answer on June 15, 2026 at 6:04 am

    My bet is that the canceled XMLHttpRequests are a result of leaving the (iframe’s) current page.

    Since you do not prevent the click event from triggering its default behavior (i.e. getting the referenced document) all the queued up event handler callbacks are being canceled once the current page unloads (keep in mind that though the AJAX calls themselves are asynchronous, the execution of the event handler callbacks is not).

    EDIT
    There actually is a limit on the number of simultaneously requests to a single domain. This limit is imposed by the browser and does vary quite a bit (2 and 6 being the most common).

    See the network test from browserscope.

    EDIT 2
    Oh and btw. you might want to use POST instead of GET to be sure the browser won’t cancel the request due to a cache hit. And if you absolutely need to make every click count, you should set the async flag to false when calling new_request.open. This way, all the requests will get queued up and run one after the other.

    Quick fix:

    var text = "Click no:-";
    var counter = 0;
    
    $("#inc").click(function() {
         var new_request = new XMLHttpRequest();
    
         var new_serverURL = "http://www.google.com";
    
         new_request.open('POST',new_serverURL,true);
         new_request.send(null);
    
        $("#container").html("<p>" + text + " " + ++counter + "</p>");
        // Prevent the link's default behavior
        return false;
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's one usecase that has been baffling me. When I select some text and
Usecase: my hotline has phone number 0815/111222333 user starts up dialer and dials that
UseCase: Assume that rating of object is from 1 to 5 stars. It is
I'm working on an usecase diagram. The customer can pay through credit card or
This might not have a major usecase in projects, but I was just trying
In python (it's a Django filter), I'm doing this: lReturn = re.sub(r'\[usecase:([ \w]+)]', r'EXTEND
Using MySQL, i have a current timestamp that looks like this: 2011-11-01 10:34:24 Is
I have something of a simple usecase: User has a set of Privileges; when
Any idea how I can relate different objects together? Usecase i am trying to
I have a user control 'A' that has another user control 'B' as its

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.