title: How do I trap a requestexception in an Ajax request in Sencha Touch 2?
body: <p>In my Sencha Touch app Ext.device.Connection.isOnline() will return true if the device is connected to wifi but doesn't have an internet connection - so my Ajax calls hang. I'm trying to trap the requestexception event so I can handle the error gracefully, but can't get it to work. Here's the code:</p>
  
  <pre><code>Ext.Ajax.request({
                  url:    [my url],
                  jsonData:{ },
                  params:{
                      op:     'myop'
  
                  },
  
                  method:"POST",
                  success:function(response, opts){
                      // all good
  
                  },
                  failure:function(response, opts){
                      // failed
                  },
  
                  listeners: {
                      requestexception: function(connection, response, options,  eOpts) {
  
  
                          switch(response.status) {
                              case 0 :
                                Ext.Msg.alert('Error Loading', 'No Internet connection.');
                                break;
  
                              default :
                                Ext.Msg.alert('Whoops!', 'An unexpected error has occurred.');
                            }
  
                      }
                  }
  
  
              });
  </code></pre>
  
  <p>Not sure what I'm doing wrong! </p>
  
  <p>Thanks
  Matt</p>