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

  • Home
  • SEARCH
  • 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 1067603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:10:43+00:00 2026-05-16T20:10:43+00:00

Issue: Attach a click event on a link on a page (say link to

  • 0

Issue:

  1. Attach a click event on a link on a page (say link to http://google.com/)

  2. Try doing an AJAX or getJSON (JQuery specific call) from the function bound to that click event

  3. The AJAX or getJSON call is never completed (even if we add an explicit half-second pause)

Sample HTML page: http://paraschopra.com/temp/bah.html

Sample Server logger (to check counts): http://paraschopra.com/temp/count.txt

The bah.html file contacts a simple PHP logger via getJSON if you click on ABC link. The logger increments the number in count.txt. You will realize on Chrome 6 (and Safari), the server never gets contacted while on FF, IE, Chrome 5 the server gets contacted. Is it a bug or what? Is there a workaround right now?

By the way, works on all other browsers: FF, IE, etc.

  • 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-16T20:10:44+00:00Added an answer on May 16, 2026 at 8:10 pm

    It’s a bug — but not in the new browsers. 🙂 What you’re doing is setting up an asynchronous Ajax call, after which the page is being torn down because a link has been clicked that takes you to a new page. Your call never completes because the page is gone.

    You can’t reliably start asynchronous Ajax calls when the page is being torn down (well, you can reliably start them, but not have them reliably complete). Your only real options as far as I know are:

    1. Make the Ajax call synchronous (blech). This makes for a noticeable delay for the user.

    2. Cancel the link’s default action and then change the window location yourself when the call completes (blech). Still a noticeable delay for the user AND it interferes with “open in new window”, “open in new tab”, etc.

    3. Approach the entire problem differently. The usual way is to have the link go to a page which then redirects to the actual target location. (That’s what Google does, for instance, in Google Groups and various other places.) This is what I’d do for a general web-facing page (intranet apps are different), not least because it’s totally reliable and works even if the user has JavaScript disabled in their browser.

    You’ll find a lot of questions and answers on this topic here on StackOverflow if you search for questions about doing things during the unload and beforeunload events.

    I wouldn’t be entirely surprised to find out there was a way to bring web workers to bear on this problem, but I expect many of the trade-offs would be the same, and web workers are only supported by a small number of browsers at present (including Chrome).

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

Sidebar

Related Questions

I am trying to attach a click event to a check box using JavaScript.
another issue in IE 6... link The navbar link list has a border applied
I'm writing a class that needs to attach event listeners to objects within a
I am using the jQuery Validation plugin and have an issue validating items that
I have a attached behavior issue. When I attach the behavior to my textbox
I'm trying to create an AppDomain and attach to its UnhandledException event from F#,
This issue came up when I got different records counts for what I thought
The issue is there is a database with around 20k customer records and I
The issue that prompted me to ask this is a web form that was
Our issue is that our project has files being downloaded using wget to the

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.