title: Update List in ViewModel with Ajax ASP .NET MVC
body: <p>I have a List (List) of Model objects which is presented in a view. I would like to add to that list without refreshing the page - therefore i thought Ajax is a great soloution. Im currently having a hard time getting it working.</p>
  
  <p>My view is rendering a PartialView which contains the list.</p>
  
  <p>Can somebody give me a hint how to pass a list to the controller and then back to the view without updating the whole page?</p>
  
  <p>I hope my question makes sense.</p>
  
  <p>/chris</p>
  
  <p>EDIT:</p>
  
  <p>I've been trying with JQuery. Looks like this:</p>
  
  <pre><code>&lt;script&gt;
  $(document).ready(function () {
      $("#btnSave").click(function () {
  
          $.ajax(
              {
                  type: "POST", //HTTP POST Method
                  url: "/Video/Index", // Controller/View
                  data: { //Passing data
                      testString: $("#txtArea").val(),
                      videoID: '@(Model.Video.iVideo_ID)',
                      taskID: document.getElementById('dropVal').value
                  }
              }).success(function () {
                  $("#proever").load("/Video/Index");
              });
      })
  })
  </code></pre>
  
  <p></p>
  
  <p>With this method i get to HttpPost method in my controller. And i pass the parameters into it succesfully.</p>
  
  <pre><code>[HttpPost]
      public ActionResult Index(CommentViewModel viewModel)
      {
          System.Diagnostics.Debug.WriteLine(viewModel.testString);
          System.Diagnostics.Debug.WriteLine(viewModel.videoID);
          System.Diagnostics.Debug.WriteLine(viewModel.taskID);
  
  
  
          viewModel.testString = "new text string";
  
          return View(viewModel);
      }
  </code></pre>
  
  <p>The problem is now that i can't get the updated viewmodel back to the view.. What am i doing wrong?
  In this example I don't update the list but just a test string to see if i can get it updated back to the view..</p>