Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sencha touch 确定internet连接是否可用_Sencha Touch_Internet Connection - Fatal编程技术网

Sencha touch 确定internet连接是否可用

Sencha touch 确定internet连接是否可用,sencha-touch,internet-connection,Sencha Touch,Internet Connection,如何在sencha touch应用程序中检查设备是否连接到互联网?有一个名为navigator.onLine的属性(一般浏览器支持,不适用于sencha) 如果我使用的是PhoneGap应用程序(如果您使用的是Sencha Touch,您通常会使用它),我宁愿使用它们的功能,因为根据经验,我发现它更可靠 John Resig在他的博客中描述了一种叫做“离线事件”的东西:。如果在ajax请求期间没有网络连接,sencha touch将返回一个状态为0的响应。这就是我们在应用程序中使用的内容(也适用

如何在sencha touch应用程序中检查设备是否连接到互联网?

有一个名为
navigator.onLine的属性(一般浏览器支持,不适用于sencha)

如果我使用的是PhoneGap应用程序(如果您使用的是Sencha Touch,您通常会使用它),我宁愿使用它们的功能,因为根据经验,我发现它更可靠


John Resig在他的博客中描述了一种叫做“离线事件”的东西:。

如果在ajax请求期间没有网络连接,sencha touch将返回一个状态为0的响应。这就是我们在应用程序中使用的内容(也适用于phonegap):

请注意,这是针对Touch1.1的,尚未在2.0中试用过

// 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.');
  }
});