title: Delete record by using ajax from database EntityFramework
body: <p>I am beginner and trying to delete the record from database by using <code>JavaScript</code>, <code>Ajax</code> and <code>Json</code> in <strong>MVC Entity Framework</strong>. But my delete button is not working well.</p>
  
  <p>In controller class my action code is</p>
  
  <pre><code>public ActionResult Delete(int id) {
              using (StudentContext db = new StudentContext()) {
                  Student std = db.Student.Where(x =&gt; x.Id == id).FirstOrDefault&lt;Student&gt;();
                  db.Student.Remove(std);
                  db.SaveChanges();
                }
                return Json(true, JsonRequestBehavior.AllowGet);
          }
  </code></pre>
  
  <p>and my JavaScript code is</p>
  
  <pre><code>&lt;button id='deleteRecord'&gt;delete&lt;/button&gt;
  
  $("#deleteRecord").click(function () {
                  var StudentId = $(this).val();
                  var stdId = parseInt(StudentId);
                  $.ajax({
                      url: "/AjaxStudent/Delete",
                      type: 'Delete',
                      data: {
                          StudentId: stdId
                      }
                  }).done(function () {
                      alert("Deleted")
                  });
              });
  
          }).error(function () {
              alert("Failed")
          });
  </code></pre>
  
  <p>I shall be very thankful if anybody help me.</p>