Sencha Touch 2 Ajax基本身份验证请求在Android上失败

时间:2013-06-27 01:47:33

标签: ajax webview cordova sencha-touch-2 basic-authentication

我有一个Sencha Touch 2.2.0应用程序,包含在Phonegap / Cordova 2.7.4中。它对使用HTTP基本身份验证的REST API进行简单的ajax调用。

Ext.Ajax.request({
    url: 'http://localhost:3000/test',
    method: 'GET',

    // timeout occurs on invalid credentials?
    timeout: 2000,
    //enable basic authentication
    withCredentials: true,
    // need useDefaultXhrHeader: false and disableCaching: true to get cookies to work.
    useDefaultXhrHeader: false,
    disableCaching: true,

    username: 'username',
    password: 'password',
    success: function(response) {
        // process JSON data...

    },
    failure: function(response) {

        console.log('Login failed. response.status:' + response.status +
            ', response.statusText:' + response.statusText +
            ', response.responseText:' + response.responseText);

        // invalid credentials appears to timeout...
        // response.status:0, response.statusText:communications failure, response.responseText: undefined
    }
});

此代码在iOS设备上运行正常,但在Android上运行不正常?

  

... D / CordovaLog(1967):登录失败。 response.status:401,   response.statusText:未经授权,response.responseText:未经授权

如果我在默认的android浏览器中运行此应用程序(托管在本地apache开发Web服务器上),则浏览器会提示我输入凭据。我怀疑ajax请求超时等待凭据。无论凭据是否正确,再次,它适用于iOS?

有什么想法吗?

0 个答案:

没有答案