0

我打 Ajax 电话:

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

我怎样才能获得 Location 标头?

当我尝试这样做时:

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

我有错误

无法读取未定义的属性“位置”

4

1 回答 1

0

寻找解决方案:

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);
            }
        });
于 2013-06-22T17:46:32.943 回答