wij数据源错误
当使用 wijhttpproxy 请求 wijdatasource 完成并且数据有一些问题时,有没有办法调试或出现错误?
data: new wijdatasource({
dynamic: true,
proxy: new wijhttpproxy({
url: "@Url.Action("List")",
type: "POST",
dataType: "json"
}),
reader: {
read: function (datasource) {
alert(datasource);
var count = datasource.data.TotalRowCount;
datasource.data = datasource.data.Items;
datasource.data.totalRows = count;
new wijarrayreader([
{ name: "CdCF", mapping: "CdCF" },
{ name: "Descrizione", mapping: "Descrizione" }
]).read(datasource);
}
}
})
使用 Internet Explorer 调试器,我可以看到调用是通过对 List 操作的 200 HTTP 响应进行的,但“alert(datasource);”永远不会被执行。 我想得到使数据源无法解析数据的错误(如果这是错误)。 在标准 ajax 调用中,我可能有一个“错误”回调来尝试调试问题。
$.ajax({
error: function (error) {
alert("error: " + error);
},
url: '@Url.Action("List")',
success: function (code) {
var myModel = {
items: eval(code)
};
}
});
Is there a way to debug or get an error when wijdatasource complete is request with a wijhttpproxy and have some problems with the data?
data: new wijdatasource({
dynamic: true,
proxy: new wijhttpproxy({
url: "@Url.Action("List")",
type: "POST",
dataType: "json"
}),
reader: {
read: function (datasource) {
alert(datasource);
var count = datasource.data.TotalRowCount;
datasource.data = datasource.data.Items;
datasource.data.totalRows = count;
new wijarrayreader([
{ name: "CdCF", mapping: "CdCF" },
{ name: "Descrizione", mapping: "Descrizione" }
]).read(datasource);
}
}
})
With the internet explorer debugger I can see the call is made with a 200 HTTP response to the List action but "alert(datasource);" is never executed.
I want to get the error that make the datasource not parse the data (if this is the error).
In a standard ajax call I could have had an "error" callback to try to debug the problem.
$.ajax({
error: function (error) {
alert("error: " + error);
},
url: '@Url.Action("List")',
success: function (code) {
var myModel = {
items: eval(code)
};
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您想要执行 Get 而不是 Post。
I think you want to do a Get instead of a Post.
我所做的是,我捕获了控制器中的错误,并修改了我发送回的对象,使其具有一个“成功”布尔值,我在读取函数上检查了该值,以便如果 datasource.data.success 为 true,那么我将处理数据如果没有我会吐出一条消息。您必须将控制器操作中的所有内容都放在 try-catch 块内。
What I did is that I caught the error in the controller an modified the object I was sending back to have a "success" boolean that I checked on the read function so that if datasource.data.success was true, then I would process the data if not I would spit out a message. You would have to put everything in your controller action inside a try-catch block.