title: ajax post global function vs repeat the same function for each request
body: <p>I have something that i do not understand . 
  I do  have a global function AjaxPost() 
  that take url and data than send them to backend .
  it calls the function but the parameters are always null . </p>
  
  <p>So i take the same content of the function and used it directly in the request , it works perfectly . 
  this One Doesn't work  //example : AjaxPost("/Road/DeleteRoad", road);</p>
  
  <pre><code>function AjaxPost(url, data) {
      return $.ajax({
          type: "post",
          url: url,
          contentType: "application/json;charset=utf-8",
          dataType: "json",
          data: JSON.stringify(data)
      });
  }
  </code></pre>
  
  <p>this one works perfectly   </p>
  
  <pre><code> $.ajax({
          type: "post",
          url: "/Road/DeleteRoad",
          contentType: "application/json;charset=utf-8",
          dataType: "json",
          data: JSON.stringify(road)
      });
  </code></pre>
  
  <p>Here the action method </p>
  
  <pre><code> [HttpPost]
      public async Task&lt;IActionResult&gt; DeleteRoad([FromBody]r road)
      {
          int.TryParse(road.RoadID, out int RoadID);
          if (RoadID &gt; 0)
          {
              await _road.DeleteRoad(RoadID);
          }
          return RedirectToAction("Index");
      }
  </code></pre>
  
  <p>Here is the class r</p>
  
  <pre><code>  public class r
      {
          public string RoadID { get; set; }
      }
  </code></pre>
  
  <p>Here Is The Road object 
  //for example : </p>
  
  <pre><code>  var road ={
      RoadID :4,
      }
  </code></pre>