jquery - 如果登录会话在 laravel 应用程序中过期,jQuery 如何捕获?
问题描述
在我的 Laravel 8 应用程序中,我使用 jQuery 3.5.1 并想知道是否有办法以防登录会话过期以在 1 个位置捕获此错误以从应用程序注销?
就像我在 vuejs 中一样:
this.$http.interceptors.response.use(undefined, function (error) {
return new Promise(function (/*resolve, reject*/) {
if (typeof error.response.status !== 'undefined' && error.response.status === 401) {
self.$store.dispatch('logout') // DEBUGGING
self.showPopupMessage('Access', 'Not authorized !', 'warn')
...
}
解决方案
推荐阅读
- android - 如何在 Android 11 中创建目录
- angular - 自定义 Angular 库在 Web 应用程序中引发 NullInjector 错误
- python - 交叉验证错误 DataConversionWarning:当需要一维数组时,传递了列向量 y
- flutter - GestureDetector ontap 不起作用,但 ondouble tap 起作用。扑
- java - Log4J2 - 只写入日志文件而不是控制台
- sql - 两列之间存在差异的 WHERE 子句
- visual-studio - “System.NullReferenceException”类型的第一次机会异常
- php - 如何确保每个事件只能通过 codeigniter 中的 role_id 查看(只有超级管理员可以查看所有列表)?
- php - 如何将数据传递给外部程序并取回结果
- istio - Istio 服务到服务流量加密