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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:07:24+00:00 2026-05-27T00:07:24+00:00

Can someone tell me why the javascript code below causes renewSession() to be called

  • 0

Can someone tell me why the javascript code below causes renewSession() to be called 7 times after a single click?

$(document).ready(function () {
    $("*").mouseup(function () {
        renewSession();
    });
});

function renewSession() {
    $.ajax({
        url: "/Account/RenewSession",
        type: "POST"
    });
}
  • 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-27T00:07:25+00:00Added an answer on May 27, 2026 at 12:07 am

    Probably it’s because the mouseup event propagates up through the DOM tree, and you’re applying the handler to every element in the document. So it’ll fire on the first element, and then the parent and so on until it gets to the html (or the body, I can never quite remember without checking every time).

    You could use:

    $(document).ready(function () {
        $("*").mouseup(function (e) {
            e.stopPropagation();
            renewSession();
        });
    });
    

    To prevent the multiple calls.


    Edited to address comment from thiag0:

    Thanks for the quick response…what I am trying to do is call renewSession() every time the user clicks on the site to keep the session alive. This solution prevents the renewSession from getting called multiple times in a single click but prevents the actual intent of the user’s click from firing. Anyway to get around this?

    You could just target the body element; so long as events are allowed to propagate through the DOM tree (so long as you’re not calling event.stopPropagation() on elements between the element clicked on (or ‘mouseup’-ed) then the event(s) will propagate to the body. So I’d suggest using:

    $(document).ready(function () {
        $("body").mouseup(function () {
            renewSession();
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can someone please tell me why my code below doesn't work? Code below should
Can someone tell me what exactly the two above lines of javascript do? And
am currently studying jquery, can someone tell me the things that javascript native can
Can someone tell me what the code equivelant in VB.Net to this C# code
Can someone tell me where to add the small piece of code to have
Can someone tell what does the following code (its used in master page) do
Can someone please tell me what's wrong with this code? Basically what I am
Can someone tell me how Titanium appcelrator works under the hood? How the javascript
Can someone tell me how i can change the .xml file that a flash
Can someone tell me the different between LinkButton.PostBackUrl and HyperLink.NavigateUrl? I've got a asp.net

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.