title: How to pass string to Controller using AJAX
body: <p>I cannot seem to do this very simple task of passing a string to a controller when a button is pressed. The data received, is always null. Can someone tell me what I'm doing wrong?</p>
  
  <p>Form:</p>
  
  <pre><code>&lt;form&gt;
      &lt;div class="form-group"&gt;
          &lt;label for="ProcessName" class="control-control"&gt;Process Name&lt;/label&gt;
          &lt;input id="ProcessName" class="form-control" placeholder="Choose process name"&gt;
          &lt;small id="subtitle" class="form-text text-muted"&gt;Text under input field.&lt;/small&gt;
      &lt;/div&gt;
      &lt;button type="submit" class="btn btn-primary" id="addElement"&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>$(function () {
      $("#addElement").click(function () {
          var processName = $("#ProcessName").val();
  
          // I've tried this method
          $.post('@Url.Action("AddProcessName")', processName, function (data, status) {
                      alert(data)
          });
  
         // And also this one, but both of them don't work.
         // I did not try them at the same time, of course
          $.ajax({
              type: "POST",
              url: '@Url.Action("AddProcessName")',
              data: processName,
              dataType: 'text',
              success: function (response) {
                  alert(response)
                  };
          });
      });
  });
  </code></pre>
  
  <p>Server side:</p>
  
  <pre><code>[HttpPost]
  public IActionResult AddProcessName(string data)
  {
      pm.ID = 1;
      pm.Name = data; // I put a breakpoint here to check the value of 'data'
      return Content(pm.Name);
  }
  </code></pre>