title: How to Receive Ajax Data values from Controller in asp mvc
body: <p>using the following script, I am trying to access the variables being sent using data in the ajax function but I couldn't.</p>
  
  <pre><code>&lt;script&gt;
  $('#inline-username').click(function () {
      var comments = $('#inline-username').val();
      //var selectedId = $('#hdnSelectedId').val();
  
      $.ajax({
          url: '@Url.Action("UpdateOrder")', // to get the right path to controller from TableRoutes of Asp.Net MVC
          dataType: "json", //to work with json format
          type: "POST", //to do a post request
          contentType: 'application/json; charset=utf-8', //define a contentType of your request
          cache: false, //avoid caching results
          data: { test: $(this).text() }, // here you can pass arguments to your request if you need
          success: function (data) {
              // data is your result from controller
              if (data.success) {
                  alert(data.message);
              }
          },
          error: function (xhr) {
              alert('error');
          }
      });
  });
  </code></pre>
  
  <p>here is the action in the controller</p>
  
  <pre><code>public ActionResult UpdateOrder()
      {
          // some code
          var test = Request.Form["test"];
          return Json(new { success = true, message = "Order updated successfully" }, JsonRequestBehavior.AllowGet);
      }
  </code></pre>
  
  <p>I tried <code>Request.Form["test"]</code> but the value of it is null. how should I receive the objects of <code>data</code>?</p>