title: View does not display updated values asp.net mvc
body: <p>We want to perform some calculations on some values in a view...so when the user enters a value in a input...we want to go back to the server...perform the calculations and "refresh" the view with the new values...With the code as it is now, it enters the correct (...or at least the one I ask it to) controller action, correctly performs the calculations and returns the updated ViewData to the view. When I step thru the loop that builds the html for the view, the ViewData has the updated values, but when the View is displayed on the browser, the values have not changed...</p>
  
  <p>Here's the javascript  </p>
  
  <pre><code>$('input.changeValue').change(function() {
      $('body').css('cursor', 'wait');
      var changedAmt = this.value;
      var frmUpdate = $('form#frmUpdate').serializeArray();
  
      fooSoldObj = new Object();
      fooSoldObj.name = 'fooSoldAmt';
      fooSoldObj.value = changedAmt;
  
      frmUpdate[frmUpdate.length] = fooSoldObj;
  
      $.ajax(
              {
                  type: $('form#frmUpdate')[0].method,
                  url: $('form#frmUpdate')[0].action,
                  data: frmUpdate,
                  dataType: 'html',
                  error: function(error) {
                      alert('frmUpdate error' + error);
                  }
              }
          ); 
  
      setTimeout(function() {
          $('body').css('cursor', 'default');
      }, 0);
  });
  </code></pre>
  
  <p>Here's what the html for the form frmUpdate looks like  </p>
  
  <pre><code>&lt;form action="/Forecast/Update" id="frmUpdate" method="post" name="frmUpdate"&gt;
      &lt;span&gt;
          &lt;input id="HiddenForecastID" name="HiddenForecastID" type="hidden" value="XXX" /&gt;
          &lt;input id="HiddenForecastYear" name="HiddenForecastYear" type="hidden" value="2009" /&gt;
          &lt;input id="HiddenForecastMonth" name="HiddenForecastMonth" type="hidden" value="3" /&gt;       
      &lt;/span&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Now just to confuse things further, the data that is not displaying correctly is in a different form on the view. The reason (right or wrong) I have two forms is that the other form on the view kicks off a save routine.</p>
  
  <p>Here's the relevant part of the controller action </p>
  
  <pre><code> [AcceptVerbs(HttpVerbs.Post)]
      public ActionResult Update(FormCollection frmUpdate)            
      {
          //go off and do some stuff...this part works as the ViewData 
          //is correct....meaning it has the updated values that
          //we want to see displayed in the view
          return View("MyView", ViewData[someData]);
  
      }
  </code></pre>
  
  <p>I'm thinking that maybe the reason it's not working is that I'm updating one form and then asking the MVC view engine to update/refresh the other form(but keep in mind that when I step thru the loop on the view that builds the page, the data is updated but the page in the browser is not)...How can I cause the view to display the correct html?</p>
  
  <p>/********************************************<br>
  Added the following code just to test RedirectToAction<br>
  The ajax call DOES NOT error on the above return View("blah") stuff<br>
  **********************************************/  </p>
  
  <p>P.S. Just tried RedirectToAction in the controller like this  </p>
  
  <pre><code> [AcceptVerbs(HttpVerbs.Post)]
      public ActionResult Update(FormCollection frmUpdate)            
      {
          //go off and do some stuff...this part works as the ViewData 
          //is correct....meaning it has the updated values that
          //we want to see displayed in the view
          return RedirectToAction("MyView", new RouteValueDictionary( new { controller = "Forecast", action = "MyView", addMonth = monthAdd } ) );
      }
  </code></pre>
  
  <p>but then the ajax call errors with a 500 error</p>
  
  <p>Thanks,<br>
  Greg</p>