0

I want to delete multiple row on html table which has checked an I dont want to use post method . How can ı send Id Array to send Controller.I am using EF6 Thanks For Help.

$.ajax({
    url: "/Urun/DeleteField" + '/' + DeleteArray,
    type: "DELETE",
    dataType: "JSON",
    data: JSON.stringify(DeleteArray),
    cache: false,
    success: function(node) {
        if (node.success) {
            alert("İşlem Başarılı");
        } else alert("İşlem Başarısız");
    }
});
while (DeleteArray.length > 0) {
    DeleteArray.pop();
}
Dhaval Marthak
  • 17,246
  • 6
  • 46
  • 68

2 Answers2

0

On server side:

[HttpDelete]
public JsonResult TestDelete(List<int> Ids)
{
    //your businbes logic goes here
    return Json(new { success = true}); //return example
}

On client side:

var DeleteArray = [1, 2, 3, 4]; //your array example
$.ajax({
    url: "@Url.Action("TestDelete","Home")", // create urls properly
    type: "DELETE",
    dataType: 'json',
    contentType: "application/json, charset=utf-8", 
    data: JSON.stringify({ Ids: DeleteArray }),
    cache: false,
    success: function (node) {
        if (node.success) {
            alert("Success"); //your success callback logic goes here
        } else alert("Fail");
    }
});
aleha_84
  • 8,309
  • 2
  • 38
  • 46
0

I have fixed with this lines in web.config...

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
</system.webServer>`
aleha_84
  • 8,309
  • 2
  • 38
  • 46