I currently have an entire website built on one index.html
document. There is a div
element with id: #contentDiv
that I just keep replacing the content inside by using AJAX to get different html snippets and then replacing the content with JQuery .html()
function like so:
function getContent(content, path, location) {
$.ajax({
type: 'get',
url: 'http://localhost:4000/REST/getHTML',
dataType: 'json',
data: {
'file': content,
'path': path
},
success: function (data, status) {
var html = data['html'];
$('#' + location + 'Content').html(html);
},
complete: function (data, status) {
//alert(status);
}
});
}
My question is: Upon reloading the page, is it possible to keep the current state of the DOM? Currently, it takes me back to my home page (the original state of the website before doing any AJAX calls). I've tried messing around with pushState()
and also different variations of JQuery replacement methods (i.e. instead of .html()
, using .empty()
and then .append()
)