javascript from ajax doesn't get proper execution
<p>Using Ajax, I've created a sort of console that allows me to execute some PHP functions dynamically.</p>

<p>It looks like this <a href="https://i.stack.imgur.com/Wj2Ww.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wj2Ww.png" alt="screenshot"></a></p>

<p>The problem is that after a bunch of commands, the console becomes hard to read. So I've created a javascript function, named "wipe();", which clears the <code>&lt;div&gt;</code> containing the console.</p>

<p>I tested this function with the developpers tools of chrome (the javascript console) and it works perfectly.</p>

<p>But when I try to call this function by making the PHP-AJAX return a "&lt;script>wipe();&lt;/script>", it doesn't work. It does nothing.</p>

<p>I've read on the internet that all the "&lt;script>&lt;/script>" works independently from each other, but that <strong>you can call a <code>&lt;script&gt;function&lt;/script&gt;</code> from another &lt;script>&lt;/script> block</strong>. </p>

<p>So why is it failing to do that ?</p>

<p>here is the php code :</p>

<pre><code>    echo '&lt;script&gt;wipe();&lt;/script&gt;';
</code></pre>

<p>and here is the the first &lt;script> block:</p>

<pre><code>        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)+'&lt;br&gt;'+xmlhttp.responseText+'&lt;br&gt;&lt;br&gt;';
           }
           xmlhttp.send();
         }

    function wipe(){
             span.innerHTML = '';
        }
</code></pre>