如果我了解您要发生的事情,那么这就是我的实现方式。它在Prototype中而不是jQuery中,但是您花的时间不会花很多时间来翻译:
new Ajax.Request('process.php', { on401: function(response) { var redirect = response.getHeader('Location'); document.location = redirect; }});如果会话处于非活动状态,则在PHP中输出以下内容:
header('Location: http://example.com/login.php', true, 401);exit;


