How to pass id for delete operation using JQuery in MVC4.0 application?

Delete operation is common utility in every application hence I have tried to make it simple by passing id which we want to delete. It has been done through jquery. jQuery.ajax() which performs an asynchronous HTTP (Ajax) request is included in this article.

Description: You can call WEB-API method from JQuery and pass parameters through JQuery.
In this code snippet I have added code which should be under script tags in view (.cshtml) page.
If request is successful then alert message is displayed on the screen.

<script type="text/javascript">
function deleteData(id, first_parameter, second_parameter, third_parameter) {

var my_output = confirm("Do you want to delete " + third_parameter + "?");
if (my_output) {
var carryforward_data = $.ajax({
url: '/yournamespaceName/your_controller_name/your_action_name',
type: 'POST',
data: { "ID": id, "col1": first_parameter, "col2": second_parameter },
dataType: 'json',
cache: false
}); (jqXHR, textStatus)
alert("Request failed: " + textStatus);
carryforward_data.success(function (output_data) {
if (output_data.success) {
alert("Result is - '" + third_parameter + "' deleted successfully");


return true;
else {
return false;



'your_action_name' is action in which delete functionality is written. Delete can be of soft delete or delete from database.


Guest Author: Adil18 Sep 2013

Hi Westfall Family. My name is Meghan Marne, and I am 15 years old. I have an 18 year old reining Quarter Horse named Magic, and I love him to Pisces. I've been with Magic for about a year and a half now. But every time I take him to a reining show, even if its a small potluck at our home arena, he loses his cool. He tenses and bolts through the entire pattern, utterly anxious and upset. When we are riding at home, (me, Magic, and sometimes my trainer Abby), he is a very talented refiner, and an all around happy horse. He showed in his younger years, and did very well. Do you think he is just done with showing? I love him so much, and don't want to move on to another horse, but I also don't want to put him through something that makes him upset. Do you have any suggestions, or any ideas about how to help my horse to be happy and calm at shows? Thank you for your time, and please answer back!p.s. I started reining after seeing your bridles ride with Roxy! Thank you for the inspiration!

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: