title: Executing Javascript in Ajax-called page
body: <p>I need to send some data with Ajax call to a PHP file that parses it, renders a graph with d3js (thus having some Javascript in it), extracts resulting SVG (more JS) and saves it to an SQL (via another ajax call). So it's like a sequence of 3 pages/files:
  data manipulation page --> graph/svg renderer --> SQL upload with PHP</p>
  
  <p>The problem is, if I submit 1st page, the Javascript of 2nd page is not executing. If I copy the request of 1st page to another window, it works fine.</p>
  
  <p>Simplified, the files are like this:</p>
  
  <p>test_ajax_1.php:</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;script type="text/javascript" src="../addons/jquery-1.10.2.min.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;script type="text/javascript"&gt;
        $(document).ready( function() {
          var request = $.ajax({
            url: "test_ajax_2.php",
            type: "get",
            data: {
              graph : '123'
            }
          });
        });
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>test_ajax_2.php:</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;script type="text/javascript" src="../addons/jquery-1.10.2.min.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;script type="text/javascript"&gt;
        $(document).ready( function() {
          var renderedGraph = "&lt;svg&gt;&lt;? echo $_GET['graph']; ?&gt;&lt;/svg&gt;";
          var request = $.ajax({
            url: "test_ajax_3.php",
            type: "get",
            data: {
              newGraph : renderedGraph
            }
          });
        });
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>test_ajax_3.php:</p>
  
  <pre><code>&lt;?php
    $renderedGraph = $_GET['newGraph'];
    $connect_db=mysqli_connect('localhost', 'this', 'that', 'whatnot');
    $result = $connect_db-&gt;query("UPDATE the_table SET svg='$renderedGraph' WHERE id = '1'");
  ?&gt;
  </code></pre>
  
  <p>If I go to www.mysite.com/test_ajax_1.php, nothing happens</p>
  
  <p>If I go to www.mysite.com/test_ajax_2.php?graph=123, if works fine.</p>
  
  <p>The actual question is, is it possible to have Javascript executed on Ajax-called page, or should I find some other approach?</p>