title: How to pass parameters from Ajax function to controller action?
body: <p>I have a button in my view that calls a jQuery Ajax function passing in parameters from my model</p>
  
  <pre><code>&lt;input type="button" value="Run Check" onclick="runCheck('@actionItem.StepID', '@Model.Client.DatabaseConnectionString', '@Model.Client.ClientID')" /&gt;
  </code></pre>
  
  <p>The jQuery function</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          function runCheck(x, y, z) {
              $.ajax({
                  url: '@Url.Action("ProcessFeedbackHasRows", "Client")',
                  type: 'POST',
                  contentType: 'application/json;',
                  data: { stepId: x, databaseConnectionString: y, clientId: z },
                  success: function (data) {
                      if (data.IsValid) {
                          //alert('true');
                          var url = '@Url.Action("ViewProcessingFeedBackPartial", "Client")';
                          $("#processingFeedbackPartialDiv").load(url, { stepId, databaseConnectionString, clientId },
                              function () {
                                  $("#confirmButton").removeAttr("style");
                              });
                      } else {
                          //alert('false');
                          var newUrl = '@Url.Action("Processing", "Client")';
                          window.location = newUrl;
                      }
                  }
              });
      };
  &lt;/script&gt;
  </code></pre>
  
  <p>And finally my controller action</p>
  
  <pre><code>public JsonResult ProcessFeedbackHasRows(int StepId, string DatabaseConnectionString, int ClientID)
      {
          bool isValid = true;
          FeedbackDetails feedbackDetails = new FeedbackDetails();
  
          feedbackDetails.Data = _clientProcessingService.GetProcessingFeedbackDetails(StepId, DatabaseConnectionString);
  
          if (feedbackDetails.Data.Rows.Count == 0)
          {
              _clientProcessingService.RunProcessStepConfirmation(DatabaseConnectionString, StepId, ClientID, "No information returned, automatically proceeding to next step.");
              isValid = false;
          }
  
          return Json(new { IsValid = isValid });
      }
  </code></pre>
  
  <p>The logic in the ajax function works when I hard code specific values in the controller to represent the appropriate step, client &amp; database but when I debug I see the two integers as <code>0</code> and the string as <code>null</code>.</p>
  
  <p>How can I pass these values to the controller?  I considered just storing them in <code>ViewBag</code> or <code>ViewData</code> but that seems clunky and not really a good practice.</p>