I want to load a list from a div
, from one page to another (both on my server). I know that there is a jquery $('#content').load('paginaexemplo.htm' '#lista')
, but I'd like to know how I do this with
I want to load a list from a div
, from one page to another (both on my server). I know that there is a jquery $('#content').load('paginaexemplo.htm' '#lista')
, but I'd like to know how I do this with
You can do this with XMLHttpRequest:
var http = new XMLHttpRequest();
var url_ = "pagina.php"; // página de onde virá a div
http.open("GET", url_, true);
http.onreadystatechange = function(){
if(http.readyState == 4){
var html = http.responseText;
// converte o retorno em elementos HTML
html = new DOMParser().parseFromString(html, "text/html");
document.getElementById('id_da_div_que_irá_receber').innerHTML = html.getElementById('id_da_div_que_de_onde_virá').innerHTML.trim();
}
}
http.send(null);