I have a logic where I want to insert data into database. SO I am sending ajax
request through my local machine. Below is the code for the same..
$("#btnSubmitCT").on('click', function () {
var valid = validateForm();
if (valid) {
$("#divLoadingPanel").show();
SubmitForm_CE().done(function () {
$("#divLoadingPanel").hide();
});
}
});
function SubmitForm_CE() {
try {
var req_id = "";
var umsGroupNameBy = CurrentGroupName;
var umsGroupIdBy = CurrentGroupID;
var loginUserName = LoginUserName;
var spanType = $(spantypeid + ' option:selected').val().toUpperCase();
var r4gState = $(r4gstatediv + ' option:selected').text();
var UG_LEN = parseFloat($('#UGLEGCE_txt').html()).toFixed(4);
var AR_LEN = parseFloat($('#ARLEGCE_txt').html()).toFixed(4);
var fixedUG = parseFloat($('#UGLEGCE_txt').html()).toFixed(4);
var fixedAR = parseFloat($('#ARLEGCE_txt').html()).toFixed(4);
var linkId;
var spanId;
var createdId;
if (spanType == AppConfig.SpanTypeInter.toUpperCase()) {
linkId = "";
spanId = $(spnLinkId).text();
createdId = "SPAN ID: " + spanId;
}
else {
spanId = "";
linkId = $(spnLinkId).text();
createdId = "LINK ID: " + linkId;
}
var mZoneCode = $(mzoneid + ' option:selected').val();
var mZoneText = $(mzoneid + ' option:selected').text();
var mZoneArr = mZoneText.split('/');
var mZoneName = mZoneArr[0];
var operationType = $(activitytypeid + ' option:selected').val().toUpperCase();
var pendSpanLeg = parseFloat($(pendingSpanLen).html());
var neLeg = parseFloat($(spnspanlength).html());
var offerHoto = parseFloat($(hotoofferbyct).val());
var offerDate = $('#ctOfferdatepicker').val();
var remark = $(remarkct).val();
var offerValue = JSON.stringify({ "OFFERHOTO": offerHoto, "OFFERLIT": "0", "NE_LEG": neLeg, "HOTOCOMPLETED": "0", "LITCOMPLETED": "0" });
var statusId = getHotoStatusID(offerValue);
var umsGroupObj = JSON.parse(UMSGroupDetails)
var GroupToValue = "";
var umsGroupNameTo = "";
var umsGroupIdTo;
$.each(umsGroupObj, function (index, element) {
if (element.GroupName == UserGrouop.FE) {
umsGroupNameTo = element.GroupName;
umsGroupIdTo = element.GroupID;
}
});
var Values = { "SPANID": spanId, "LINKID": linkId, "CREATEDBY": loginUserName, "MZONECODE": mZoneCode, "MZONENAME": mZoneName, "NELEG": neLeg, "UGLEG": UG_LEN, "ARLEG": AR_LEN, "STATUSID": statusId, "HOTOOFFERDATE": offerDate, "REMARK": remark, "HOTOOFFERLEG": offerHoto, "UMSGROUPIDBY": umsGroupIdBy, "UMSGROUPNAMEBY": umsGroupNameBy, "UMSGROUPIDTO": umsGroupIdTo, "UMSGROUPNAMETO": umsGroupNameTo, "SPANTYPE": spanType, "R4GState": r4gState };
return $.ajax({
type: "POST",
url: AppConfig.PrefixURL + "App/InitiateWF_CT",
data: JSON.stringify(Values),
contentType: "application/json; charset=utf-8",
dataType: "json",
// async: false,
beforeSend: function () {
},
success: function (response) {
alert(response);
var datalist = JSON.parse(response);
var state = datalist.split('|')[0];
var msg = "";
if (state == "SUCCESS") {
msg = "Request Id: " + datalist.split('|')[1] + " has been created for " + createdId;
req_id = datalist.split('|')[1];
hideInfoWindow();
hideLoading();
jAlert(msg, ValidationMessageConfig.Title, function () {
$(spandetailsdiv).hide();
deleteSpanListDatatable_CT($(spnLinkId).text());
});
} else if (state == "WARNING" || state == "EXISTS") {
msg = datalist.split('|')[1];
hideInfoWindow();
hideLoading();
jAlert(msg, ValidationMessageConfig.Title, function () {
$(spandetailsdiv).hide();
deleteSpanListDatatable_CT($(spnLinkId).text());
});
} else {
hideLoading();
msg = datalist.split('|')[1]
jAlert(msg, ValidationMessageConfig.Title, function () {
$(spandetailsdiv).hide();
deleteSpanListDatatable_CT($(spnLinkId).text());
});
AppLog.getLogger('error', "Error occured during processing new job");
}
},
error: function (response) {
// jAlert(ErrorMessageForMethods.initiateWF, ErrorMessageForMethods.Title);
//AppLog.getLogger('error', "Error occured during processing new job");
// hideLoading();
alert('NO Record created 1');
hideLoading();
}
});
} catch (e) {
$(spandetailsdiv).hide();
hideLoading();
alert('NO Record created 2');
//jAlert(ErrorMessageForMethods.initiateWF, ErrorMessageForMethods.Title);
//AppLog.getLogger('error', "Error occured during processing new job");
}
}
url: AppConfig.PrefixURL + "App/InitiateWF_CT",
here it is telling that http://localhost:2126/App/InitiateWF_CT 500 (Internal Server Error)
Can you suggest what is wrong in this ?
2
Answers
There clearly not enough information to say what’s causing that 500 error:
I would recommend you following steps:
A 500 Internal Server Error typically indicates that there is an issue in the server-side code or maybe in configuration.since the error is occurring when making a POST request to http://localhost:2126/App/InitiateWF_CT, it’s more likely that issue within the server-side code of the InitiateWF_CT endpoint.You can log it and check…