0

I have 16 database results shown on my website. Using a load more button, the user can load the next 16 database items and they get appended into the container.

Im trying to make a way so that if the user clicks back after visiting a link, they will get shown the same amount of results as they had loaded.

My plan for this is to add a page number to the url after each load more function. When the user clicks back in the browser, i can then use that parameter in the LIMIT php claus.

So, in my ajax response, i append the data and then i wish to add a page number to the url, or update the page number if there already is one.

An example of what i want to achieve is:

www.mydomain.com/?page=1

I have made a jsfiddle with a basic button click function just for testing since im away from my laptop until later.

jsFiddle

And the code just incase:

var url = document.URL;
var pageID = '1';
$("#addtourl").click(function(){
    // add page id to the url
    alert(url);
});

Where the url is alerted i want to modify the URL. I already create a page ID so thats not an issue.

Thanks!

Lovelock
  • 6,609
  • 15
  • 71
  • 162

1 Answers1

2

You can use the HTML 5 history.pushState function as explained here .

Community
  • 1
  • 1
Kaz
  • 572
  • 1
  • 6
  • 20