title: how to call controllers function with ajax when click button MVC
body: <p>Im new in MVC,I have problem the button cannot call Ajax function to render Action in controller.</p>
  
  <p>this bellow my script button </p>
  
  <pre><code>&lt;input type="submit" value="show" class="btn btn-success" name="submitButton" onclick="OnActionClick()" /&gt;
  </code></pre>
  
  <p>My Ajax</p>
  
  <pre><code>function OnActionClick() {
      alert("Error when update data");   
      $.ajax({
              type: "GET",
              url: "@Url.Content("~/Report/ViewReport")",
              data: {
                  name:'try'
              },
              success: function () {
                 alert("ok"); 
              },
              error: function () {
                  alert("Error when update data");                    
              }
          });        
  }
  </code></pre>
  
  <p>and here my Action in controller</p>
  
  <pre><code>public ActionResult ViewReport(string name)
      {
          Database db = new Database("Collections");
          List&lt;report&gt; data = new List&lt;report&gt;();
          data = db.Fetch&lt;report&gt;(@"select top 10 * from SampleTbl where name = @0",new object[]{name});
          return View(data);
      }
  </code></pre>