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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:09:41+00:00 2026-05-24T12:09:41+00:00

I had an idea to keep my users’ sessions alive by sending a webservice

  • 0

I had an idea to keep my users’ sessions alive by sending a webservice call, setting a timeout for a set amount of time (like 15 mins or so) then recall that same method.

Problem is the webservice appears to fire off continuously. Not every 15 mins like I thought.

A link can be found here: Fiddle

Code here:

(function($, window, document, undefined) {
    "use strict";

    var methods, 
        settings,
        timeout,
        type = 'sessionPing';

    methods = {
        init: function () { 
            settings = { time: 5000};

            methods.request.call(this);
        },

        request: function () { 
            console.log('just before clear' + timeout);
          clearTimeout(timeout);

            $.ajax({ type: 'POST',
                   url: '/echo/html/',
                   data: {
                    'html': 'Echo!'
                   },
                   success: function(data) {
                     timeout = setTimeout(methods.request(), settings.time);  
                       console.log('in success ' + timeout);
                   },
                   dataType: 'html'
                });  
        }
    };

    $.sessionPing = function(method) {
        // Method calling logic
        if (methods[method]) {
            return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        } else if (typeof method === 'object' || !method) {
            return methods.init.apply(this, arguments);
        } else {
            $.error('Method ' + method + ' does not exist on jQuery.timeSince');
        }
    };

}(jQuery, window, document));


$(function() {
    $.sessionPing();
});    
  • 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-24T12:09:41+00:00Added an answer on May 24, 2026 at 12:09 pm
    timeout = setTimeout(methods.request(), settings.time);
    

    Your parentheses there will automatically run methods.request, which in turn will run code that automatically runs methods.request on down the line; basically, the method will execute over and over again, binding increasingly more versions of itself to your interval.

    timeout = setTimeout(methods.request, settings.time);
    

    That’s what you’re looking for: just passing the function signature instead of passing a function that executes as a side-effect.

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

Sidebar

Related Questions

I had an idea, if I add a python .py file to my C#
I had the idea of a search engine that would index web items like
I had an idea for a client-side language other than JavaScript, and I'd like
I had an idea I was mulling over with some colleagues. None of us
I had an idea that would require me be able to send and receive
I recently had an idea to create my own String class to make using
Hey guys i had an idea yesterday. Can you help me with this. Here
I am learning C# and WPF and had an idea for a little utility.
I'm interested in learning to use OpenGL and I had the idea of writing
I just got this question on an interview and had no idea how to

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.