2011-10-05 49 views
0

我很努力区分sencha touch中的响应MIME类型。我的登录服务是这样设计的,如果登录成功,那么它会给我一个JSON对象。如果未通过身份验证,则会返回计划错误文本。 我如何找到差异?我的请求看起来像这样。如何识别sencha中的响应MIME类型

Ext.Ajax.request({ 
       url : 'http://xxxx.com/Sencha/LoginServlet?userid='+ agentid + "&password=" + password,      
       type:'json',   
       success : function(response, opt) { 
        alert("response text" + response.responseText); 
        var obj = Ext.decode(response.responseText); 
        console.dir(obj); 
        App.views.viewport.reveal('nextScreen'); 
      }, 

      failure : function(response, opt) { 
       Ext.Msg.alert('Failed', response.responseText); 
      } 

      }); 

回答

2

Ext JS内部使用XMLHttpRequest对象,所以响应是w3联盟兼容。因此,您可以像在普通的javascript中那样检索响应对象属性。例如:

response.getResponseHeader("Content-Type") 

有关如何检索来自响应对象的其它细节,参见here细节。