解決AJAX應用,會話逾時(Session Timeout)的問題,粗略方法(不考慮使用Filter的前提下)

來源:互聯網
上載者:User

標籤:

function ajaxPost(url, data) {
var async = false;
var result = {};

$.ajax({
url : url,
async : async,
cache : false,
data : data,
type : "POST",
//beforeSend : function(request) {
//if(window.console){
//console.log("beforeSend");
//}
//},
//ajaxSend : function(){
//if(window.console){
//console.log("ajaxSend");
//}
//},
success : function(data){
//if(window.console){
//console.log("success");
//console.log(data.status);
//console.log(data);
//console.log(data.status);
//console.log(typeof data);
//}
if(typeof data == "string"){//返回的HTML字串
if(data.indexOf("登入") != -1){//如果HTML字串裡包含登入關鍵字
location.reload(true);
}else{
result = data;
}
}else if ( typeof data == "object" ) {//返回的JSON資料
result = data;
}
},
//ajaxSuccess : function(){
//if(window.console){
//console.log("ajaxSuccess");
//}
//},
error : function(){
//if(window.console){
//console.log("error");
//}
location.reload(true);
},
//ajaxError : function(){
//if(window.console){
//console.log("ajaxError");
//}
//},
complete : function(xhr, textStatus){
//if(window.console){
//console.log("complete");
//console.log(xhr);
//console.log(xhr.status);
//console.log(textStatus);
//}
}//,
//ajaxComplete : function(){
//if(window.console){
//console.log("ajaxComplete");
//}
//}
});

return result;
}

解決AJAX應用,會話逾時(Session Timeout)的問題,粗略方法(不考慮使用Filter的前提下)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.