Ext.util.JSONP.request 中的错误处理
我正在尝试连接到服务器,当服务器关闭时,商店应该执行某些操作。我需要知道的是如何在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对您来说可能为时已晚,但 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.