기기가 sencha touch 앱에서 인터넷에 연결되어 있는지 어떻게 확인합니까? 나는 (당신이 센차 터치를 사용하는 경우가 종종있다)을 폰갭 응용 프로그램에있어 경우인터넷 연결 가능 여부 확인
2
A
답변
3
속성이 navigator.onLine
(엽차에 대한 특정하지 일반 브라우저 지원을,)라고있다
, 차라리 사용하십시오 그들의 network.isReachable 기능, 이후 경험에 의해 더 신뢰할 수있는 것으로 나타났습니다.
'오프라인 이벤트'라는 제목의 항목도 있습니다. John Resig는 자신의 블로그 (http://ejohn.org/blog/offline-events/)에서이 이벤트를 설명합니다.
3
ajax 요청 중에 네트워크 연결이없는 경우 sencha touch는 0 상태의 응답을 리턴합니다. 그래서이 (너무 폰갭에서 작동) 우리가 우리의 응용 프로그램에서 사용하고 있습니다 :이 터치 1.1입니다
// global error handling
Ext.Ajax.on('requestexception', function(connection, response) {
// get rid of any loading masks that are present
Ext.each(Ext.query('.x-mask'), function(el) {
new Ext.Element(el).hide()
});
switch(response.status) {
case 0 :
Ext.Msg.alert('Error Loading', 'No Internet connection.');
break;
case 401 :
Ext.Msg.alert('Login Failed', 'Check your username and password.');
break;
default :
Ext.Msg.alert('Whoops!', 'An unexpected error has occurred and we have been alerted.');
}
});
참고, 아직 2.0에서 시도하지 않았습니다.