My design of a page forces me to refresh the whole page with html that I have loaded via ajax.
$(\'html\').replaceWith(data);
Gives me errors. A
this might be the solution you'll require, It replaces the entire document including its head. You won't have any issues loading your new css, js & other resources. I've assumed you receive the new html content by invoking a REST api:
$.ajax({
type: 'POST',
url: form.attr('action'),
data: form.serialize(), // serializes form elements
success: function(response) {
// re-writes the entire document
var newDoc = document.open("text/html", "replace");
newDoc.write(response);
newDoc.close();
}
});