title: passing data from javaScript to MVC controller view ajax
body: <p>This is strange, I have no clue why this is not working, no matter what I do, I am always end up receiving null for the action method parameter. Why is that not working?</p>
  
  <pre><code>&lt;input type="button" value="Save" onclick="SaveDocument()"  /&gt;
  </code></pre>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>       function SaveDocument() {
              
           var data = "sss";
  
              $.ajax({
                  url: "/Home/Save",
                  type: "POST",
                  dataType: "json",
                  contentType: "application/json; charset=utf-8",
                  data: JSON.stringify(data),
                  success: function (mydata) {
                      alert("Saved");
                  },
                  error: function(error)
                  {
                      alert('failed');
                      alert(error);
                  }
              });
            
          }
      
      &lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <pre><code>    [HttpPost]
      public ActionResult Save(string data)
      {
          return null;
      }
  </code></pre>