views:

1191

answers:

2

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. Any ideas?

+8  A: 

Use body:

$('body').replaceWith(data);
altCognito
Although this will not replace the head section, which might be required to load the necessary Javascript and CSS files necessary to render the page properly.
ngeek
Actually, jQuery does do the work of execute any embedded javascript. CSS stylesheets will absolutely be applied. Just realize that the CSS stylesheets you've removed remain in the rulesets, they don't get removed.
altCognito
A: 

Won't the html tag contain the script that is doing the replacing? If you're using the body tag make sure your html fits.

Mark Dickinson