wij数据源错误

发布于 2024-12-02 20:28:08 字数 1129 浏览 1 评论 0原文

当使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

银河中√捞星星 2024-12-09 20:28:08

我认为您想要执行 Get 而不是 Post。

proxy: new wijhttpproxy({
        url: "@Url.Action("List")",
        type: "Get",
        dataType: "json"
    }),

I think you want to do a Get instead of a Post.

proxy: new wijhttpproxy({
        url: "@Url.Action("List")",
        type: "Get",
        dataType: "json"
    }),
暮光沉寂 2024-12-09 20:28:08

我所做的是,我捕获了控制器中的错误,并修改了我发送回的对象,使其具有一个“成功”布尔值,我在读取函数上检查了该值,以便如果 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文