title: Execute a javascript function from HTTP Request
body: <p>Hi I'm trying to get a function work that I will get from an HTTP Get Request. However I can not make the script run</p>
  
  <p>My code is:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;script type="text/javascript"&gt;
  
          window.launch = function(url, has_credits) {
              if (has_credits != "True"){
                  if (!confirm(con_str)){
                      window.close();
                  }
              }
              document.getElementById("waiting_msg").innerHTML = "Loading..."
              location.href = url;
          };
  
          var xmlHttp = new XMLHttpRequest();
          theUrl = 'http://127.0.0.1:8000/game/launch/?provider=XXX&amp;game=7bal_tie&amp;token=50c63444b85cdadf5e4b9285c2be5444&amp;jsonp=launch'
          xmlHttp.open( "GET", theUrl, true );
          xmlHttp.send( null );
          //
              // The script that will trigger  the function 
          //
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The return of the request is </p>
  
  <pre><code>launch("http://my-url.com","False");
  </code></pre>
  
  <p>Which should redirect me to the said url. I hope that javascript has a builtin function that can easily run it like</p>
  
  <pre><code>func(xmlHttp.response);
  </code></pre>
  
  <p>Then will just trigger the function but I can't find any and eval did not workout for me</p>