I know this is an old post but its relevant to what I'm working on currently.
What I'm aiming to do is create next/previous page buttons at the top of a html page, and say I'm on 'book.html', with the current 'display' ID content being 'page-1.html' through ajax, if i click the 'next' button it will load 'page-2.html' through ajax, WITHOUT reloading the page.
How would I go about doing this through AJAX as I have seen many examples but most of them are completely different, and most examples of using AJAX are for WordPress forms and stuff.
Currently using the below line will open the entire page, I want to know the best way to go about using AJAX instead if possible :) window.location(url);
I'm incorportating the below code as an example:
var i = 1;
var url = "pages/page-" + i + ".html";
function incPage() {
if (i < 10) {
i++;
window.location = url;
//load next page in body using AJAX request
} else if (i = 10) {
i = 0;
}
document.getElementById("display").innerHTML = i;
}
function decPage() {
if (i > 0) {
--i;
window.location = url;
//load previous page in body using AJAX request
} else if (i = 0) {
i = 10;
}
document.getElementById("display").innerHTML = i;
}