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()
but it didn't return anything.... Even tho it explains the idea... so... can anyone tell me how to do so please? Also the content of a certain id or class in that website, something like:
var X=$(http://www.website.com/home "#id").html()
It would really help me, thanks in advance!
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With