【问题标题】:HTTP Basic Auth from sencha touch 2来自sencha touch 2的HTTP Basic Auth
【发布时间】:2013-07-01 04:38:42
【问题描述】:

我正在使用 web api 构建一个 sencha touch 2 应用程序。 api 必须在执行操作之前对每个请求进行身份验证。所以,我的问题是,如何在 Sencha 触摸应用程序的每个请求上发送用户凭据(用户名和密码)?换句话说,如何使用 Sencha touch 2 的 HTTP Basic Auth?

【问题讨论】:

    标签: sencha-touch sencha-touch-2 sencha-touch-2.1


    【解决方案1】:

    使用ajax 使用HTTP POST 请求

    Ext.Ajax.request({
        url : login',
        method : 'POST',
        params :{
            username : username,
            password : password
         },
    
        success : function(response) {
            console.log("Login successful");
            var data = JSON.parse(response.responseText);
            console.log(data);
        },
    
        failure : function(response) {
            console.log("Login failed");
        },
    
        scope : this
    });
    

    也可以看看How to do HTTP Basic Auth in Ajax

    【讨论】:

      猜你喜欢
      • 2012-04-14
      • 1970-01-01
      • 2013-08-21
      • 1970-01-01
      • 2012-05-05
      • 2013-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多