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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:49:56+00:00 2026-05-21T06:49:56+00:00

I have a view with a List of ViewModels that is based on data

  • 0

I have a view with a List of ViewModels that is based on data from my database. I present this list, but I want to the list to be refreshed on a given interval(5 secs) as the data in the database changes. I have a Action in my controller that update the ViewModels. I use MVC 3 and Razor.
I guess some JavaScript/jQuery is needed.

My script:

<script type="text/javascript">
$(document).ready(function () {
    var hdRaceId = $("#hdRaceId");

    setInterval("GetList()", 5000);
    function GetList() {
        $.get("/Timer/Update/?id=" + hdRaceId.val());
    }

My Action in my controller:

        public ActionResult Update(int id)
    {
        var raceintermediates = RaceIntermediateModel.GetRaceintermediatesForRace(id);
        return View("Speaker", raceintermediates);
    }
  • 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-21T06:49:57+00:00Added an answer on May 21, 2026 at 6:49 am

    If you want to refresh some part of the DOM you need to define a success callback to your AJAX request. Like this:

    window.setInterval(function() {
        var hdRaceId = $('#hdRaceId').val(); 
        var updateUrl = '@Url.Action("Update", "Timer")';
        $.get(updateUrl, { id: hdRaceId }, function(result) {
            $('#someDivId').html(result);
        });
    }, 5000);
    

    where you have some div that will host the partial view results:

    <div id="someDivId"></div>
    

    also some browsers like IE might cache GET requests. In order to avoid this you could use the following:

    window.setInterval(function() {
        var hdRaceId = $('#hdRaceId').val(); 
        var updateUrl = '@Url.Action("Update", "Timer")';
        $.ajax({
            url: updateUrl,
            type: 'GET',
            data: { id: hdRaceId }, 
            cache: false,
            success: function(result) {
                $('#someDivId').html(result);
            }
        });
    }, 5000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view that has a list of jobs in it, with data
I have a data grid in a view that is bound to a List
I have a list view that is periodically updated (every 60 seconds). It was
I have a list view filled with data. I set up a context menu
I currently have a list view which has several rows of data and I
I have used a list view that uses a grid view in WPF. I
I have created a list view that displays the names and dates of items
Hello. I have a list that looks like this one: public class PagedList<T> :
I have a View that displays a list of entities (L2Sql), I already have
I have a list view control which at the moment only allows one item

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.