ATlaS ATlaS - 4 months ago 11x
Javascript Question

jQuery - load html response into whole page

In my ajax code, I get a html response. How can I replace the whole page to this html response? I only find

, which only can redirct url response.

My code:

url: '/someurl',
data: {'key': value},
type: 'POST',
success: function(html_data) {
# how to load this html_data into the whole page?
error: ...


jQuery replaceWith should get it done for you ;)

$( "html" ).replaceWith( data );

Where data is html received from server...

Entire code will look something like this...

$.get( "", function( data ) {
  $( "html" ).replaceWith( data );

Learn more about jQuery here...