AJAX历史麻烦

So I have this dynamically php generated code:

<script>
    parent.document.title = 'Members | UrbanRanks';
    $("#cwrocket_button").click(function(){                                            
    $("#module").load("module.php?module=profile&user_url=cwrocket");
    window.history.pushState( null, null, '/cwrocket.html');
    parent.document.title = 'Cwrocket | UrbanRanks';
    $('html, body').animate({ scrollTop: 0 }, 'slow');
    return false;
    });
</script>
<a id="cwrocket_button" href="cwrocket.html">Cwrocket</a>

All Ajax/jQuery functions work as expected, title and url changed when clicking the link and ignoring the href that is included just for SEO purposes.

The problem is, when I hit back or forward it only changes the url on the address bar but not the Ajax content within the module div.

I would like to see if someone could help me out implementing a code to enable back and forward without reloading the whole website.

Tried doing:

window.history.pushState( {site:cwrocket}, null, '/cwrocket.html');

And while back and forward works it reloads the whole page.

Thanks in advance for anyone that solves this headache and let me know if more code is required please.

When you push the state, you will need to save information required to reload, then you will need to listen to the event when the back arrow is clicked:

window.onpopstate = function(evt) {
    // restore the previous state
}

That's a really general answer, but the event will have the state information you save when you push it, so you can use that to restore.