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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:01:33+00:00 2026-05-11T11:01:33+00:00

I want to log all clicks on a link. I’ve written a little logger,

  • 0

I want to log all clicks on a link.

I’ve written a little logger, which can be called by an url (returns an empty page). This url is called with a jquery-ajax-method. But unfortunately not every click is logged, if the user uses firefox (everything looks ok in IE).

I’ve tried many things but have no solution to this problem, have anybody a glue?

HTML-Code:

<a href='http://google.com' onclick='return loggClick();'>Click</a> 

JS-jQuery-Skript:

function loggClick(){    $.ajax({         type: 'POST',         url: 'Logger.ff', //dynamic url to logging action         data: {             sid: 'abc123' //random data         },         contentType: 'application/x-www-form-urlencoded; charset=UTF-8',         cache: false     });     return true; } 

EDIT: I’ve missed in the example that i have to pass dynamic parameters in the js-call, so it’s ‘not possible’ to remove the onclick-event 🙁

  • 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. 2026-05-11T11:01:34+00:00Added an answer on May 11, 2026 at 11:01 am

    I would start getting rid of the inline ‘onclick’ code and binding the event later:

      <a href='http://google.com' rel='outbound' >Click</a>      $('a[rel=outbound]').click(function(){          var url = this.href;          $.ajax({         async: false,         type: 'POST',         url: 'Logger.ff', //dynamic url to logging action         data: {                 sid: 'abc123' //random data                 clicked: url         },         contentType: 'application/x-www-form-urlencoded; charset=UTF-8',         cache: false      });      return true;    });  

    Also, you might have a ‘Race Condition’ occurring. In my example I have set async to false.

    This will stop the function returning and following the link before the request has been performed.

    About Async

    The reason I use async: false here is because with the default, aync is true, which means the AJAX request may only be partially transmitted by the time the browser sees return: true, and navigates away from the page.

    This is that ‘race condition’ I was mentioning. Here, its a cheap trick that avoids it by making the browser essentially come to a halt until the request is complete, and then allowing the browser to click the link.

    A more sophisticated answer would be having it return ‘false’, ( which will kill the browsers native ‘follow link’ behaviour ), and then having the real redirection performed in the complete function.

    This is not without its own issues mind, and could result in slow browsing behaviour while requests complete, allowing users time to click other links, which appear to do nothing, and then eventually one request gets through at a random time, and a seemingly random redirection occurs.

    Hence, advanced solutions include blocking the rest of the page and giving some sort of progress indication while the request completes.

    ( And hence, the complexity of this solution is an order of magnitude harder to pull off in a simple example than async: false )

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

Sidebar

Related Questions

I want to log all clicks in a MainMenu control I am using in
I want to log all toasts events in android ics (4.0.3), but I was
I am writing a server in PHP where I want to log all database
I want to log/write all Javascript errors to a text file whenever an error
I want to be able to log all JMX data accessible via jconsole. Is
I want to log the URLs of all the popup attempts in my FireFox
I want all my applications log to be centralized (ideally in near real-time). We
<a href=PHP/LogOut.php id=LogOut>Log Out</a> the link a#LogOut calls a PHP script that ends all
How can something so simple be so impossible? All I want to do is
I want to display which all user is online (real time; like any chatting

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.