Home >Web Front-end >JS Tutorial >Ajax operation global monitoring, solution to user session failure
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); }; });
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!