samedi 9 mai 2015

History API - Ajax pages + Json

I have a structure of my site like this IMAGE
I'm trying to create some page transition with ajax & history API

CODE:

history.pushState(null, null, "/members/" + dataLink + ".php" ); // update URL
console.log(dataLink);
$(".ajax-container").load('/members/single.php', function(){
     fillPage(dataLink); // load datas from json
});

Everything works fine, I can load the page correctly with datas but now I have to implement the behavior of the back button (using history api / popstate )but I've no idea how to do that because every member-page in filled with data from json.

$(window).bind('popstate', function() {
 // what inside here? It should call the previous page + the data from json like the previous ajax call
});

Any ideas?

Aucun commentaire:

Enregistrer un commentaire