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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:20:58+00:00 2026-05-13T16:20:58+00:00

I’ve got a click tracking AJAX function (calls a WebMethod on an .aspx page),

  • 0

I’ve got a click tracking AJAX function (calls a WebMethod on an .aspx page), and I need to call it when the user clicks through to a link.

Unfortunately, I’m using window.location = "newUrl" to change the page, which seems to make the AJAX call fail. Is there a way around this?

I do not need to get any information back from the AJAX call, I just need to make sure the WebMethod is called.

I’m aware that I could just redirect on the success() or failure() calls, but then I would have to wait for the clickTracking() method to run, which takes ~ 1s. That is not acceptable by the agreement in the project spec, and so is not a viable solution.

  • 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-13T16:20:58+00:00Added an answer on May 13, 2026 at 4:20 pm

    Instead of using AJAX, why don’t you just send the user to an ASPX page that records the click and then sends the location header to redirect to the new url? For instance, on link click, the following would occur:

    window.location = "/redirect.aspx?track=true&url=" + encodeURIComponent(newUrl);
    

    redirect.aspx would then handle both the tracking and the redirecting to the new URL. That’s pretty much the only way you can do it without waiting for an AJAX request to complete before sending the user on their way.

    See also: Redirecting Users to Another Page (MSDN)

    It’s probably worth noting that you see this method every day on many sites. Most commonly, they are found in ads. An AdSense ad link looks like this:

    http://www.google.com/aclk
        ?sa=L&ai=C6DnFKnl1S5zhKoSBjAeqyKzKBPOD_2ehlIXfD9WsvQsQAVDQzK______
        8BYLvOuYPQCsgBAaoEGU_Q8k4OJin9jMDXAD6KQ_2Dsv7xyokLxRY
        &num=1&ggladgrp=13269254452699041863&gglcreat=8511532373602616220
        &sig=AGiWqtwzFm2sTimBuQpkD5kazyRNkkqH3w
        &q=http://www.amazon.co.uk/s/%3Fie%3DUTF8%26keywords%3Dhello%2Bworld
    

    ish, anyway (I knocked it down a bit). When you click it, you land at http://www.google.com/aclk, which redirects you to the end site after tracking the click.

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

Sidebar

Ask A Question

Stats

  • Questions 396k
  • Answers 396k
  • 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 The onclick will run first. If onclick doesn't return false… May 15, 2026 at 2:53 am
  • Editorial Team
    Editorial Team added an answer We've figured out a way to do this - kinda.… May 15, 2026 at 2:53 am
  • Editorial Team
    Editorial Team added an answer In IIS 7, this can be found under Request Filtering.… May 15, 2026 at 2:53 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.