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

Asked

Viewed 43 times

0

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

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

I had the same problem once, but it’s been a while and I can’t remember how to fix 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();
  • Is missing "./app/getresult.php, true close ...

  • The code is working, it calls the page to my div, only the jquery I had in getresult.php does not work, a simple Alert does not work, if I access the address of the getresult.php page in the browser then jquery works.

  • Check the console for any kind of error and also you closed the quotes as the wmsouza commented?

1 answer

0

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

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

$(function(){loadDoc();});
setInterval (loadDoc, 5000 );

Browser other questions tagged

You are not signed in. Login or sign up in order to post.