I have designed a simple ajax request for deleting a file from database in mvc. for that i am using javascritp ajax with swal prompt for delete. But it is not working. I am getting .then undefined error.
Here is the code--
$(".btnDel").click(function () {
var NewFileName = $(this).val();
var id =@Model.Pd.Id;
console.log(id);
console.log(NewFileName);
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
icon: "warning",
buttons: [
'No, cancel it!',
'Yes, I am sure!'
],
dangerMode: true,
})
.then(function (isConfirm) {
if (isConfirm) {
$.ajax({
type: "POST",
url: "@Url.Content("~/ManageProducts/DeleteExistingFile")/",
data: { 'id': id, 'fileName': NewFileName },
success: function (data) {
swal("Message.", data, "success");
location.reload();
},
error: function () {
swal("", "Something went wrong", "error");
}
});
}
else
{
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
});

