我在sencha touch 2中创建了一个ajax请求,当我收到成功消息时,如何将我的返回值设置为session并请告诉我一个方法,我也可以从会话中获取值。
submitLoginForm: function() {
var form = this.getLoginForm().getValues();
Ext.Ajax.request({
url: '../../authenticate.php',
method: 'POST',
params: {
email: form.email,
password: form.password
},
success: function(response) {
var json = Ext.decode(response.responseText);
if(json.message == 'success') {
Ext.Msg.alert('Login Success.....');
//Here i want to store return data in session
} else {
Ext.Msg.alert('Invalid Login Or Password.....');
}
},
failure: function(response) {
Ext.Msg.alert('The request failed.....');
}
});
},
答案 0 :(得分:1)
关于成功响应,使用HTML5本地存储来设置和获取会话变量:
var sessionObject = { 'var1': 1, 'var2': 2, 'var3': 3 };
// Put the session object into storage
localStorage.setItem('sessionObject ', JSON.stringify(sessionObject ));
// Retrieve the session object from storage
var sessionObject = localStorage.getItem('sessionObject ');
console.log('sessionObject : ', JSON.parse(sessionObject ));