2013-06-21 3 views
0

Я делаю Ajax вызов:Сенча Touch 2 Как получить заголовки ответа

Ext.Ajax.request({ 
      url : 'http://apps.dhis2.org/demo/dhis-web-commons-security/login.action', 
      callbackKey : 'callback', 
      method : 'POST', 
      params : { 
       j_username : username, 
       j_password : password 
      }, 
      withCredentials : true, 
      useDefaultXhrHeader : false, 

      success : function(response) { 
       var text = response.responseText; 
       Ext.Msg.alert('Success', "Success login", Ext.emptyFn); 
      }, 

      failure : function(response) { 
       var text = response.responseText; 
       Ext.Msg.alert('Error', "Failure login", Ext.emptyFn); 
      } 
     }); 

имеют заголовки ответа:

Connection:Keep-Alive 
Content-Length:0 
Content-Type:text/plain 
Date:Fri, 21 Jun 2013 01:23:51 GMT 
Keep-Alive:timeout=5, max=100 
Location:http://apps.dhis2.org/demo/ 
Set-Cookie:JSESSIONID=2E5D7C7235BE37150F1FE7B30EA0244D; Path=/demo/; HttpOnly 
Vary:cookie 

Хау я могу получить заголовок расположения?

Когда я пытаюсь сделать это так:

Ext.Ajax.on('requestcomplete', 
     function(conn, response, options, eOpts) { 
      var location = options.headers['Location']; 
      Ext.Msg.alert('Success', location, Ext.emptyFn); 
     }, this); 

У меня есть ошибки

Не можете прочитать свойство 'Location' в неопределенном решения

ответ

0

Find:

Ext.Ajax.request({ 
      url : 'http://apps.dhis2.org/demo/dhis-web-commons-security/login.action', 
      method : 'POST', 
      params : { 
       j_username : username, 
       j_password : password 
      }, 
      withCredentials : true, 
      useDefaultXhrHeader : false, 

      success : function(response) { 

       var Location = response.getResponseHeader('Location'); 
      }, 

      failure : function(response) { 
       Ext.Msg.alert('Error', "Failure login", Ext.emptyFn); 
      } 
     });