我在控制器中有两个AJAX POST方法可以实现相同的功能。两次发布在屏幕上的两个标签中进行, 问题是第二个仅在第一次发布完成后才起作用。第一次使用第二种发布方法时,它不起作用。
它显示控制台中的错误
加载资源失败:服务器响应状态为500(内部服务器错误)
这是两个功能
第一个
function SaveDeliverableScopeDefinition() {
debugger;
if (_checkedArray.length == 0) {
notyAlert("warning", "No rows selected");
}
else {
var csv = _checkedArray.toString();
$('#DeliverableScopeDefinition_CheckedDeliverable').val(csv);
$.ajax({
url: 'DeliverableScopeDefinition/InsertUpdateDeliverableScope',
type: 'POST',
data: { companyID: $('#hdnCompanyID').val(), deliverableForCompany: csv, deliverableNotForCompany: null },
success: function (responsetext, status, xhr) {
debugger;
_jsonData = JSON.parse(responsetext);
_message = _jsonData.Message;
_status = _jsonData.Status;
_result = _jsonData.Records;
switch (_status) {
case "OK":
notyAlert('success', _result.Message);
ChangeButtonPatchView("DeliverableScopeDefinition", "buttonPatch", "List");
// $('#currentAccessID').text(_result.Status);
}
}
});
}
}
和第二个功能
function DeleteAssignedDeliverables() {
debugger;
if (_checkedArray.length == 0) {
notyAlert("warning", "No rows selected");
}
else {
var csv = _checkedArray.toString();
$.ajax({
url: 'http://' + window.location.host +'/DeliverableScopeDefinition/InsertUpdateDeliverableScope',
type: 'POST',
data: { companyID: $('#hdnCompanyID').val(), deliverableForCompany: null, deliverableNotForCompany: csv },
success: function (responsetext, status, xhr) {
debugger;
_jsonData = JSON.parse(responsetext);
_message = _jsonData.Message;
_status = _jsonData.Status;
_result = _jsonData.Records;
switch (_status) {
case "OK":
notyAlert('success', _result.Message);
ChangeButtonPatchView("DeliverableScopeDefinition", "buttonPatch", "List");
// $('#currentAccessID').text(_result.Status);
}
}
});
}
}
这是控制器功能
[HttpPost]
public string InsertUpdateDeliverableScope(Guid companyID,string deliverableForCompany,string deliverableNotForCompany)
{
try
{
DeliverableScopeViewModel deliverableScopeVM = new DeliverableScopeViewModel();
UA _patsUA = Session["PaTSUA"] as UA;
deliverableScopeVM.PATSCommon = new PATSCommonViewModel
{
CreatedBy = _patsUA.UserName,
CreatedDate = _patsCommon.GetCurrentDateTime(),
UpdatedBy = _patsUA.UserName,
UpdatedDate = _patsCommon.GetCurrentDateTime(),
};
var result = _deliverableScopeBusiness.InsertUpdateDeliverableScope(_mapper.MapToDeliverableScope(deliverableScopeVM), companyID, deliverableForCompany, deliverableNotForCompany,_patsUA.DBConnectionString);
return JsonConvert.SerializeObject(new { Status = "OK", Records = result, Message = "Success" });
}
catch(Exception ex)
{
return JsonConvert.SerializeObject(new { Status = "ERROR", Message = ex.Message });
//throw ex;
}
}