After passing parameter ajax call 500 Internal Server Occured
In MVC Using Ajax call Without passing parameter data getting successfullly but after pass parameter ajax call 500 Internal Server Occured
Not Working Code :
JavaScript
var AcadYear = $('#ddlAcadYear option:selected').val();
$.ajax({
type: "POST",
url: '@Url.Action("GetReportDetails", "RptStudentList")',
data: "{'AcadYear':'" + AcadYear + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
},
error: function (response) {
alert(response.d);
}
});JavaScript
function OnSuccess(response) {
$("#tblShowDetails").DataTable(
{
bRetrieve: true
})
$("#tblShowDetails").DataTable(
{
"scrollY": 500,
"scrollX": true,
destroy: true,
bSort: true,
bPaginate: true,
dom: 'Bfrtip',
data: response,
columns: [{ 'data': 'str1' },
{ 'data': 'str2' },
{ 'data': 'str3' },
{ 'data': 'str4' },
{ 'data': 'str5' },
]
});
};Working Code :
JavaScript
var AcadYear = $('#ddlAcadYear option:selected').val();
$.ajax({
type: "POST",
url: '@Url.Action("GetReportDetails", "RptStudentList")',
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
},
error: function (response) {
alert(response.d);
}
});JavaScript
function OnSuccess(response) {
$("#tblShowDetails").DataTable(
{
bRetrieve: true
})
$("#tblShowDetails").DataTable(
{
"scrollY": 500,
"scrollX": true,
destroy: true,
bSort: true,
bPaginate: true,
dom: 'Bfrtip',
data: response,
columns: [{ 'data': 'str1' },
{ 'data': 'str2' },
{ 'data': 'str3' },
{ 'data': 'str4' },
{ 'data': 'str5' },
]
});
};
Madan ShekarRank #428 · 5.9K reputationPosted Apr 20, 2022, 10:24 AM EDT
Ravinder SharmaRank #1,211 · 1.5K reputationPosted Apr 20, 2022, 10:35 PM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Apr 24, 2022, 1:39 PM EDT