I am trying to show the exception that is being thrown because of SQL store procedure failure.I am getting the response in ajax but that is to with requst.responseText but I dont want to access the whole responseText.I need only the title of this responseText
My Controller is as Follows:
public ActionResult ReOrderSegment(string DocumentIDs, long DossierIDForReOrder)
{
try
{
var TrimmedString = DocumentIDs.TrimEnd('#');
var DocumentIDsWithInteger = Convert.ToInt64(DocumentIDs.Split('#').FirstOrDefault());
long SelectedCompany = db.Documents.FirstOrDefault(x => x.ID == DocumentIDsWithInteger).CompanyID;
var Message = db.PerformAutomatedSorting(SelectedCompany, DossierIDForReOrder, TrimmedString);
return Json(Message, JsonRequestBehavior.AllowGet);
}
catch (SqlException ex)
{
Response.StatusCode = 500;
Response.TrySkipIisCustomErrors = true;
return Json(new { errorMessage = ex.Message }, JsonRequestBehavior.AllowGet);
}
return Json(0);
}
and JS:
$.ajax({
type: 'POST',
url: rootUrl("Dossier/ReOrderSegment"),
dataType: "json",
data: { DocumentIDs: DocumentIDs, DossierIDForReOrder: DossierIDForReOrder },
traditional: true,
success: function (rest)
{
alert(rest);
},
error: function (request, status, error)
{
//var all = JSON.parse(request.responseText);
alert(request.responseText);
}
});
});
here i am attaching the images

here i want to show only "Please select only Air Product that are UnInvoiced" in alert.