Why Juery post method converts into get method ?
I have a jquery method with post method, and it is working fine in my local machine.
But when I uploaded on window IIS server and tried to run it was not working. I checked in "Network" tab using inspect element, it was calling "get" method instead of "post"
Issue
function fnConfirm(model) {
$('#myModalDelete').modal('show');
$("#DeleteDiv").html("Are you sure you want to delete this record?");
$("#ConfirmDeleting").click(function () {
$.ajax({
url: "Controller/DeleteData/" + model.id,
type: 'post',
contentType: 'application/x-www-form-urlencoded',
data: $(this).serialize(),
success: function (data, textStatus, jQxhr) {
$('#myModalDelete').modal('hide');
table.ajax.reload(null, false);
},
error: function (jqXhr, textStatus, errorThrown) {
console.log(errorThrown);
}
});
});
}
Solution
I have changed two things,
1. set URL in lowercase
2. set type in uppercase
Now, its working fine in Live server as well as in local machine.
1. set URL in lowercase
2. set type in uppercase
function fnConfirm(model) {
$('#myModalDelete').modal('show');
$("#DeleteDiv").html("Are you sure you want to delete this record?");
$("#ConfirmDeleting").click(function () {
$.ajax({
url: "headerlinks/deletedata/" + model.id,
type: 'POST',
contentType: 'application/x-www-form-urlencoded',
data: $(this).serialize(),
success: function (data, textStatus, jQxhr) {
$('#myModalDelete').modal('hide');
table.ajax.reload(null, false);
},
error: function (jqXhr, textStatus, errorThrown) {
console.log(errorThrown);
}
});
});
}
Now, its working fine in Live server as well as in local machine.
Hope this will help you and save your time.
Enjoy !!!
:)