Home >Web Front-end >JS Tutorial >Global monitoring of ajax operations, how to deal with user session failure
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); }; });
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!