My site uses History.js HTML5 History/State API (pushState, statechange event etc) and loads the page into my .content div via AJAX (jQuery).
Works fine until I do a URL redirection server side (CakePHP $this->redirect($url);). The content updates fine with the page I redirected to, but I would like to add a new state to the history.
How should I do this? Is there a way I can check the AJAX response to know if the request was redirected or should I approach the problem from another direction?
Example
Admin listing of blog posts. /posts/index
User selects a post. /posts/open/13
User clicks "Delete post" /posts/delete/13
After deleting from DB, the request gets redirected to the listing, but the address bar is still /posts/delete/13
I would like to replace the current state (/posts/delete/13) with the new URL to the history (/posts/index). But how would I know if the AJAX request was redirected or not?
{status:200, url:'/posts/index'}- Markus Hofmann