I have an ajax call that looks like this:
$.ajax({
url: '@Url.Action("SaveStudy")',
type: "POST",
contentType: 'application/json',
data: JSON.stringify({
....irrelevant data
}),
success: function (result) {
....irrelevant data
},
error: function (result) {
//alert("I had an error");
}
});
The error section of that ajax call is reached when logic in my controller sends back a HttpStatusCodeResult. The controller code looks like this:
if (Participants==null)
{
return new HttpStatusCodeResult(409, "No Players were selected!");
}
Is there a way to get that error message 'No Players were selected' to display in an alert (or anything, really) in the error section of my AJAX call?