剑道:在阿贾克斯的数据请求处理错误 [英] Kendo: Handling Errors in Ajax Data Requests
本文介绍了剑道:在阿贾克斯的数据请求处理错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用的剑道在UI的 MVC4 我有一个电网,使阿贾克斯作为数据回调到控制器
Using Kendo UI in MVC4 I have a Grid that makes Ajax calls for data back into the Controller:
public ActionResult SearchUser_Read([DataSourceRequest]DataSourceRequest request)
{
var data = CreateAnExcaptionHere();
return Json(data.ToDataSourceResult(request));
}
我如何使用这个电话通知,有网页错误?
How do I use this call to inform the page that there was an error?
推荐答案
如果您需要显示来自服务器的错误信息,那么你可以只用了错误的属性集返回DataSourceResult对象做到这一点:
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"
});
和使用该把它捡起来在客户端(由 .Events(事件=&GT引用; events.Error(onError的))
行):
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.");
}
}
这篇关于剑道:在阿贾克斯的数据请求处理错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文