Niestandardowy komunikat o błędzie z HTTPStatusCodeResult & jQuery
Mam akcję kontrolera, która zwraca niektóre wyniki JSON do wtyczki jQuery Full Calendar. WracamHTTPStatusCodeResult
z niestandardowym komunikatem o błędzie, jeśli wystąpił błąd, ale nie mogę wyświetlić niestandardowego komunikatu o błędzie. Wszystko, co jest wyświetlane w oknie alertu, to domyślny status HTTP (tj .: „Niedozwolony” lub „Wewnętrzny błąd serwera”)
Kod kontrolera, który zwraca komunikaty o błędach
<code>else if(id != CurrentUser.UserId) { return new HttpStatusCodeResult(403, "You are not authorised to view this."); } else { return new HttpStatusCodeResult(500, "There was an error on the server."); } </code>
kod jQuery
<code>$(document).ready(function () { $('#calendar').fullCalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' }, height: 600, eventSources: [{ url: events, type: 'Get', error: function(response, status, error) { alert(response.statusText); } }], allDayDefault: false, selectable: true, eventClick: function (event) { if (event.url) { $('#details').load(event.url); } }, </code>