admin管理员组文章数量:1026952
In my application, I'm loading some table using AJAX. But when user's session times out it gives me login page as response that gets loaded in table area.
I would like to redirect to login page may be in javascript when session timeout occurs during AJAX call.
In my application, I'm loading some table using AJAX. But when user's session times out it gives me login page as response that gets loaded in table area.
I would like to redirect to login page may be in javascript when session timeout occurs during AJAX call.
Share Improve this question asked Oct 14, 2010 at 6:30 Chinmayee GChinmayee G 8,1072 gold badges33 silver badges41 bronze badges 1- I am too late to think a question like this and found yours. in any page load (server side) i check for user existence. if they are not logged in then i will just die a string which will contain ajaxtimeout. Most of my own libraries check for responsetext.indexof('ajaxtimeout') and in this case i will window.location = login page. – Jayapal Chandran Commented Oct 15, 2010 at 6:44
2 Answers
Reset to default 5When rendering the login page you could append a custom HTTP header to the response: X-LOGIN-PAGE: True
. Then perform your AJAX call and check for the presence of this custom header in the success callback. Act accordingly if present.
You can check for the authentication in the method being called by the AJAX call and if not found can just return a flag. In the AJAX handler in the client page, you can detect and redirect to the login page.
In my application, I'm loading some table using AJAX. But when user's session times out it gives me login page as response that gets loaded in table area.
I would like to redirect to login page may be in javascript when session timeout occurs during AJAX call.
In my application, I'm loading some table using AJAX. But when user's session times out it gives me login page as response that gets loaded in table area.
I would like to redirect to login page may be in javascript when session timeout occurs during AJAX call.
Share Improve this question asked Oct 14, 2010 at 6:30 Chinmayee GChinmayee G 8,1072 gold badges33 silver badges41 bronze badges 1- I am too late to think a question like this and found yours. in any page load (server side) i check for user existence. if they are not logged in then i will just die a string which will contain ajaxtimeout. Most of my own libraries check for responsetext.indexof('ajaxtimeout') and in this case i will window.location = login page. – Jayapal Chandran Commented Oct 15, 2010 at 6:44
2 Answers
Reset to default 5When rendering the login page you could append a custom HTTP header to the response: X-LOGIN-PAGE: True
. Then perform your AJAX call and check for the presence of this custom header in the success callback. Act accordingly if present.
You can check for the authentication in the method being called by the AJAX call and if not found can just return a flag. In the AJAX handler in the client page, you can detect and redirect to the login page.
本文标签: javascriptSession timeout response in AJAXStack Overflow
版权声明:本文标题:javascript - Session timeout response in AJAX - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745653802a2161476.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论