Ext.util.JSONP.request 中的错误处理

发布于 2024-12-29 02:17:56 字数 1113 浏览 1 评论 0原文

我正在尝试连接到服务器,当服务器关闭时,商店应该执行某些操作。我需要知道的是如何在 Sencha touch 中捕获该错误/异常。任何帮助将不胜感激。

Ext.util.JSONP.request({
                    url: "http://"+serverAdd+":"+ port+"/users/searchresults.json",
                    format: 'json',
                    callbackKey: 'callback',
                    params : searchCriteria,
                    callback: function(data) {

                                    store.getProxy().clear();
                                    store.data.clear();
                                    store.sync();
                    if(data.length < 10){
                    store.add({title: 'No Results found.'},
                          {company: 'Please try again !!'},
                          {posting_date: new Date()});
                    }
                                    else{store.add(data);}
                    },
                    failure: function ( result) { 
                    alert('Failed');
                                        console.log( 'Server not connected, please try again .. ');
                    }
                });

I am trying to connect to a server and when the server is down, the store should do something. All I need to know is how to catch that error/exception in Sencha touch. Any help would be greatly appreciated.

Ext.util.JSONP.request({
                    url: "http://"+serverAdd+":"+ port+"/users/searchresults.json",
                    format: 'json',
                    callbackKey: 'callback',
                    params : searchCriteria,
                    callback: function(data) {

                                    store.getProxy().clear();
                                    store.data.clear();
                                    store.sync();
                    if(data.length < 10){
                    store.add({title: 'No Results found.'},
                          {company: 'Please try again !!'},
                          {posting_date: new Date()});
                    }
                                    else{store.add(data);}
                    },
                    failure: function ( result) { 
                    alert('Failed');
                                        console.log( 'Server not connected, please try again .. ');
                    }
                });

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

魔法少女 2025-01-05 02:17:56

对您来说可能为时已晚,但 Sencha 论坛上的某人修改了 Ext.util.JSONP.request 方法以包括设置创建的标记的“onerror”属性。该帖子是

It's probably too late for you, but someone on the Sencha forums modified the Ext.util.JSONP.request method to include setting the "onerror" attribute of the created tag. The post is here. Unfortunately, this method requires modifying the Sencha library code to implement.

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