title: refresh viewmodel on intervals mvc
body: <p>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.</p>
  
  <p>My script:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function () {
      var hdRaceId = $("#hdRaceId");
  
      setInterval("GetList()", 5000);
      function GetList() {
          $.get("/Timer/Update/?id=" + hdRaceId.val());
      }
  </code></pre>
  
  <p></p>
  
  <p>My Action in my controller:</p>
  
  <pre><code>        public ActionResult Update(int id)
      {
          var raceintermediates = RaceIntermediateModel.GetRaceintermediatesForRace(id);
          return View("Speaker", raceintermediates);
      }
  </code></pre>