Replace HTML page with contents retrieved via AJAX Replace HTML page with contents retrieved via AJAX ajax ajax

Replace HTML page with contents retrieved via AJAX


The simplest way is to set the new HTML content using:

document.open();document.write(newContent);document.close();


try this with jQuery:

$('body').load( url,[data],[callback] );

Read more at docs.jquery.com / Ajax / load


Here's how to do it in Prototype: $(id).update(data)

And jQuery: $('#id').replaceWith(data)

But document.getElementById(id).innerHTML=data should work too.

EDIT: Prototype and jQuery automatically evaluate scripts for you.