Is there a way to set a javascript variable as the content of another HTML page?
I tried:
var X = $(http://www.website.com/home).html()
It sounds like you're looking for this:
$.get('otherPage.html').then(function(responseData) {
//responseData is the contents of the other page. Do whatever you want with it.
$('#someElem').append(responseData);
});
Live demo (click).
$.get()
is a shorthand method for jQuery's $.ajax()
. http://api.jquery.com/jquery.ajax/