Home > Web Front-end > JS Tutorial > body text

Ajax operation global monitoring, solution to user session failure

韦小宝
Release: 2018-01-09 09:55:20
Original
1292 people have browsed it

The following editor will bring you an article about global monitoring of ajax operations and solutions to user session failure. The editor thinks it's pretty good, so now I'll share the ajax source code with you and give it as a reference. If you are interested in ajax, please follow the editor to take a look.

Global monitoring of ajax operation, solutions 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


The above article about global monitoring of ajax operations and solutions to user session failure is all the content shared by the editor. I hope it can give you a reference. I hope everyone will support the PHP Chinese website.

Related recommendations:

Ajax submission form page refreshes quickly with examples

ajax session login needs to be refreshed to output data

How to jump to the login page after Ajax Session failure

The above is the detailed content of Ajax operation global monitoring, solution to 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!