0

I am currently working on a page that displays a graph which can be modified by clicking on some buttons. To display the graph, I use amCharts script (see http://amcharts.com). The code that displays the chart is generated dynamically using ASP. However, I have a problem when reloading the graph when the user clicks on one of the buttons. I try to clear the div in which the graph is written and load the new JS script using :

document.getElementById("flashcontent").innerHTML = ""; 
var head = document.getElementsByTagName("HEAD")[0];
var node = document.createElement('script');
node.type = 'text/javascript';
node.async = true;
node.src = strQueryString;  
head.appendChild(node);

I verified a lot of time that the strQueryString variable is right and the Firebug says that the right script is loaded. However, the div is cleared but my JS is not executed. Note : all my JS is loaded dynamically using a similar code when the page is loaded.

Thanks !

zeacuss
  • 2,563
  • 2
  • 28
  • 32
user1553136
  • 328
  • 5
  • 17

2 Answers2

0

It might depend on the script you are trying to execute, ie, it might just be functions that are not called, but just defined. You may also want to try a different approach, which is to make an AJAX requests after load, which returns JavaScript that then is executed by the browser.

zeacuss
  • 2,563
  • 2
  • 28
  • 32
0

I solved my problem ! It was due to an event on the AmCharts side, namely the AmCharts.ready function for those who are interested.

user1553136
  • 328
  • 5
  • 17