If you need to display an error message from the server then you can do it by returning a DataSourceResult object with only its Errors property set:
return this.Json(new DataSourceResult
{
Errors = "my custom error"
});
And pick it up on the client by using this (referenced by the .Events(events => events.Error("onError"))
line):
function onError(e, status) {
if (e.status == "customerror") {
alert(e.errors);
}
else {
alert("Generic server error.");
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…