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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:38:11+00:00 2026-06-05T10:38:11+00:00

I am using Matt Schmidt’s jQuery Timer plugin /* * * jQuery Timer plugin

  • 0

I am using Matt Schmidt’s jQuery Timer plugin

/*
*
*  jQuery Timer plugin v0.1
*    Matt Schmidt [http://www.mattptr.net]
*
*  Licensed under the BSD License:
*    http://mattptr.net/license/license.txt
*
*/

jQuery.timer = function (interval, callback) {
    /**
    *
    * timer() provides a cleaner way to handle intervals  
    *
    *  @usage
    * $.timer(interval, callback);
    *
    *
    * @example
    * $.timer(1000, function (timer) {
    *   alert("hello");
    *   timer.stop();
    * });
    * @desc Show an alert box after 1 second and stop
    * 
    * @example
    * var second = false;
    *  $.timer(1000, function (timer) {
    *    if (!second) {
    *      alert('First time!');
    *      second = true;
    *      timer.reset(3000);
    *    }
    *    else {
    *      alert('Second time');
    *      timer.stop();
    *    }
    *  });
    * @desc Show an alert box after 1 second and show another after 3 seconds
    *
    * 
    */

    var interval = interval || 100;

    if (!callback)
        return false;

    _timer = function (interval, callback) {
        this.stop = function () {
            clearInterval(self.id);
        };

        this.internalCallback = function () {
            callback(self);
        };

        this.reset = function (val) {
            if (self.id)
                clearInterval(self.id);

            var val = val || 100;
            this.id = setInterval(this.internalCallback, val);
        };

        this.interval = interval;
        this.id = setInterval(this.internalCallback, this.interval);

        var self = this;
    };

    return new _timer(interval, callback);
};

I use it in the following chain:

$(document).ready(function () {
        // Get the requestId
        var requestId = $('#RequestId').val();
        var timerInterval = 10000;
        // On document load create a timer which will poll the controller every second
        $.timer(timerInterval, function (timer) {
            $.ajax(
                {
                    type: 'GET',
                    url: "/CreateFIS/GetRequestStatus",
                    data: { strRequestId: requestId },
                    success:
                        function (response) {
                            alert(response);
                            if (response != null) {
                                switch (response.toString()) {
                                    case 'Pending':
                                        // The request is still currently awaiting processing
                                        $('#InformationSpan').html('The request is currently Pending. Please Wait...');
                                        timer.stop();
                                        timer.reset(timerInterval);
                                        break;
                                    case 'Cancelled':
                                        // The request has been cancelled
                                        $('#InformationSpan').html('The request has been cancelled.');
                                        timer.stop();
                                        break;
                                    case 'Error':
                                        // There was an error with the request
                                        $('#InformationSpan').html('There has been an error generating the request. Please contact the administrator regarding this error.');
                                        break;
                                    case 'In Progress':
                                        // Generation is in progress
                                        $('#InformationSpan').html('The request is currently in progress, and will be with you shortly. Please Wait...');
                                        timer.stop();
                                        timer.reset(timerInterval);
                                        break;
                                    case 'Generated':
                                        // Generation has finished
                                        $('#InformationSpan').html('The request has finished generating.');
                                        timer.stop();
                                        //Todo redirect to viewer
                                        break;
                                    default:
                                        break;
                                }
                            }
                        },
                    error: function (req, status, error) {
                        alert(req);
                        alert(status);
                        alert(error);
                    }
                });
        });
    });

My problem is, the ajax call is only actually performed once, where I want it to be perfromed each time the timers interval is hit.
I have tried removing the calls to stop() before the call to reset(), however this makes no difference.

Am I missing something obvious?

Edit: I dont think this really matters, but here is the method on my controller:

public JsonResult GetRequestStatus(string strRequestId)
        {
            Guid requestId;
            bool result = Guid.TryParse(strRequestId, out requestId);
            if(!result)
            {
                // TODO handle error here
                return null;
            }
            FISServiceClient fisServiceClient = new FISServiceClient();
            var status = fisServiceClient.GetFISRequestStatus(requestId);
            if (status == null) return null;
            return Json(status.FISRequestStatusName, JsonRequestBehavior.AllowGet);

        }
  • 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-06-05T10:38:14+00:00Added an answer on June 5, 2026 at 10:38 am

    Your interval is set to run every 10 seconds, not every second as your comment indicates. I’ve updated the number of milliseconds to the correct 1,000, and created a jsFiddle here:

    http://jsfiddle.net/ySHUQ/

    Everything seems to work properly (obviously receiving the error alerts every second, since the URL doesn’t exist). Perhaps you just weren’t waiting long enough?

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

Sidebar

Related Questions

I'm using Matt Dotson's Real World GridView in an ASP.NET 4 page, connecting to
I'm using Matt Gallagher's AudioStreamer to play MP3s over HTTP. I need to know
I'm using Matt Gemmell's MAAttachedWindow ( http://mattgemmell.com/source ) with an NSStatusItem to display a
I'm using jQuery Tabs UI with standard the tabs structure ( http://jqueryui.com/demos/tabs/ ). I
using Matt's util code (a bit edited for Unicode text) public class GridViewExportUtil {
Using C# for ASP.NET and MOSS development, we often have to embed JavaScript into
I'm using Matt Gallagher's Audio Streaming Project . I downloaded the code/project and it
I'm using a version of Matt Gemmell's MGTwitterEngine, and I'm trying to get some
Edit: changing .ready() call per Matt's suggestion. I use jQuery to configure some stuff
I've been using compass from http://compass-style.org/ to manage my sites css for a long

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.