As we have seen in our previous Ajax requests we can grab data from different sources to output the the page. But what happens if the client has logged timmed out ? Trying to send the client to a login page can be a little more tricky than it sounds.
In this screencast I will show you a quick way to listen for unauthorized access and send the client to a login page.
Screen Time: 12:20
Please see below the key piece of code you will need.
$().ajaxError(function(xhr, status, err){ if(status.status == 401) window.location.href = '/welcome/login.php'; });