我有一个控制器操作,可以将一些 JSON 结果返回到 jQuery Full Calendar 插件。如果出现错误,我会返回HTTPStatusCodeResult
带有自定义错误消息的 a,但我无法显示自定义错误消息。警告框中显示的只是默认的 Http 状态(即:“禁止”或“内部服务器错误”)
返回错误消息的控制器代码
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.");
}
jQuery代码
$(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);
}
},