title: Searching Records From a DataBase MVC and Ajax Json Jtable
body: <p>For a few hours I'll try to do search from the database. I wrote the code to find the data from the database when you click, but it does not work. After clicking nothing has changed, and I wish searched for example, "John" ... Someone help me why this is?</p>
  
  <p>MyController.cs</p>
  
  <pre><code>using System.Collections.Generic;
  using System.Data;
  using System.Data.Entity;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using Project_MVC;
  
  namespace Project_MVC.Controllers
  { 
      public class MyController : Controller
      {
          private mydatabase db = new mydatabase();
  
  
          [HttpPost]
          public JsonResult CheckData(string name = "",string cityid = "", int jtStartIndex = 0, int jtPageSize = 0, string jtSorting = null)
          {
              try
              {
  
                  //Get data from database
                  using (var ls = new mydatabase())
                  {
                      Wdata = ls.Procedure_ShowData(name,cityid).ToList&lt;Procedure_ShowData_Result&gt;();
                  }
  
  
  
                  //Return result to jTable
                  return Json(new { Result = "OK", Records = Wdata });
              }
              catch (Exception ex)
              {
                  return Json(new { Result = "ERROR", Message = "No good" });
              }
          }
  
  }
  }
  </code></pre>
  
  <p>My.cshtml</p>
  
  <pre><code>&lt;div&gt;
  
          Name: &lt;input type="text" name="name" id="name" /&gt;
         CityId: &lt;input type="text" name="cityid" id="cityid" /&gt;
          &lt;button type="submit" id="LoadRecordsButton"&gt;Load records&lt;/button&gt;
  
  &lt;/div&gt;
  &lt;script&gt;
      $('#Check').jtable({
              messages: polishMessages,
              paging: true, //Enable paging
              pageSize: 10,
              sorting: true,
  
              actions: {
                  listAction: '@Url.Action("Check")'
  
              },
              fields: {
              Name: {
                      title: 'Name',
                      width: '20px'
                  },
                  CityId: {
                      title: 'CityId',
                      width: '20px'
                  }
              }
          });
   $('#LoadRecordsButton').click(function (e) {
              e.preventDefault();
              $('#Check').jtable('load', {
                  Name: $('#name').val(),
                  CityId: $('#cityId').val()
              });
          });
          $('#LoadRecordsButton').click();
  
      });
  &lt;/script&gt;
  </code></pre>