Using Ajax, I created a console that allows me to execute some PHP functions dynamically.
Looks like this 
The problem is that after several console commands it becomes difficult to read. So I created a javascript function called "wipe ();" that clears the <div> containing the console.
I tested this feature with the chrome development tools (javascript console) and it works great.
But when I try to call this function, returning PHP-AJAX "<script> wipe (); </script>", it does not work. He does not do anything.
I read on the Internet that all "<script> </script>" work independently of each other, but you can call the <script>function</script> from another <script> </script> block .
So why is this failing?
here is the php code:
echo '<script>wipe();</script>';
and here is the first <script> block:
var xmlhttp = new XMLHttpRequest(); var span = document.getElementById("screen"); function send(data) { window.setInterval(function() { var elem = document.getElementById('screen'); xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", "./_rcons-transmetter.php?data="+data, true) xmlhttp.onloadend = function() { span.innerHTML = span.innerHTML+escapeHtml(data)+'<br>'+xmlhttp.responseText+'<br><br>'; } xmlhttp.send(); } function wipe(){ span.innerHTML = ''; }
source share