I have a Ajax site that works with jQuery and History.js, when a link is clicked I execute this:
var $this = $(this), // $(this) is the link
url = $this.attr('href'),
title = $this.attr('title') || null;
History.pushState(null, title, url);
event.preventDefault();
Then I look the statechange for make the ajax call and change the page content:
$(window).bind('statechange', function () {
var State = History.getState(),
url = State.url
$.ajax({
url: url,
success: function (data, textStatus, jqXHR) {
// I change the content etc etc
}
});
But the Referrer header is always the URL which is being requested, so for example, I click a a link with href "/test" on my page "/home", then the code will send the ajax call to /test, but in that request it send as referrer the same "/test" and no "/home".
I trie to make the ajax call after the pushState, and it work fine it sends the referrer fine, but the back button just stop working, it change the url but not the content so, i need to look for statechange again.
What can I do?
Sorry for my english and thanks!