Home > Web Front-end > JS Tutorial > Global monitoring of ajax operations, how to deal with user session failure

Global monitoring of ajax operations, how to deal with user session failure

php中世界最好的语言
Release: 2018-04-04 14:07:39
Original
1437 people have browsed it

This time I will bring you the global monitoring of ajax operation, how to deal with the failure of user session, what are the precautions for handling the global monitoring of ajax operation, and the failure of user session, the following is the actual combat Let’s take a look at the case.

ajax operation global monitoring, solution to user session failure

jQuery(function ($) {
// 备份jquery的ajax方法 
var _ajax = $.ajax;
// 重写ajax方法,先判断登录在执行success函数 
$.ajax = function (opt) {
var _success = opt && opt.success || function (a, b) { };
var _opt = $.extend(opt, {
success: function (data, textStatus) {
try {
if (data.sessionstatus == false) {
//用户失效进行操作
//return;
} 
} catch (e) {
}
_success(data, textStatus);
}
});
_ajax(_opt);
};
});
Copy after login

I believe you have mastered the method after reading the case in this article, and there will be more exciting things Please pay attention to other related articles on php Chinese website!

Recommended reading:

How to deal with Session failure when ajax accesses it

Ajax asynchronous upload file list (with code)

The above is the detailed content of Global monitoring of ajax operations, how to deal with user session failure. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template