EXTJS 实现session 的另一种方法

JS:
  1. function showResult(btn){
  2.         //Session过期,返回登录页面
  3.         top.location.href='login.html';
  4. };
  5. check_login=function(){
  6. Ext.Ajax.request({
  7.                     url: './inc/session.asp',
  8.                     success: function(response, options) {
  9.                       var responseArray = Ext.util.JSON.decode(response.responseText);                                            
  10.                             if(responseArray.success==false){
  11.                                                                 Ext.MessageBox.show({
  12.                                                                         title: '会话超时',
  13.                                                                         msg: '您的会话已由于超时而过期,请您重新登录!',
  14.                                                                         buttons: Ext.MessageBox.OK,
  15.                                                                         fn: showResult,
  16.                                                                         icon: Ext.MessageBox.WARNING
  17.                                                                 });
  18.                                                         }
  19.                     }
  20.             });
  21. };
  22. check_login();
复制代码
ASP:
  1. <% response.ContentType="text/html;charset=utf-8" %>
  2. <%
  3. IF session("code")<>"" Then
  4.         Response.Write "{success: true,session:'"&session("code")&"'}"
  5. Else
  6.         Response.Write "{success: false,session:'login.html'}"
  7. End IF
  8. %>
复制代码
我想不用我再解释什么了吧,将JS代码引用到共用JS部分中就可以了。
posted @ 2012-06-26 10:14  holyes  阅读(196)  评论(0编辑  收藏  举报