Skip to content Skip to sidebar Skip to footer

Executing Javascript In Ajax-called Page

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 t

Solution 1:

You're not actually doing anything with the response you're getting from your ajax call. An easy way to run the script would be to create a hidden iframe and add the result html into it.

  $(document).ready( function() {
    var request = $.ajax({
      url: "test_ajax_2.php",
      type: "get",
      data: {
        graph : '123'
      },
      success: function(data) {
          var iframe = $("<iframe>").html(data).hide();
          $("body").append(iframe);
    });
  });

Post a Comment for "Executing Javascript In Ajax-called Page"