Jquery of my page does not work after being called by an XMLHttpRequest

0

I have the following code that takes a table in a php page and brings the table into a div in my index.

But in my page getreult.php has jquery codes, but they do not work, and if I want to perform some function when clicking on a button that has getresult.php also does not work, even putting the jquery codes in the index does not it works.

I've had the same problem once, but it's been a long time and I can not remember how to solve it.

xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
  if (this.readyState == 4 && this.status == 200) {
    document.getElementById("listview").innerHTML = this.responseText;
  }
};
xmlhttp.open("GET", "./app/getresult.php", true);
xmlhttp.send();
    
asked by anonymous 22.01.2018 / 09:20

1 answer

0

Well one of the solutions is to run the code via jquery using the .Load method:

function loadDoc(){  
    console.log( "Chamada." );
    $( "#listview" ).load( "./app/getresult.php", function() {
      console.log( "Doc carregado." );
    });     
};

$(function(){loadDoc();});
setInterval (loadDoc, 5000 );
    
22.01.2018 / 13:25