简体   繁体   中英

Cannot dynamically load JavaScript file twice in IE

I have build this page. when you click on a row in the table, the page send an ajax request for data and then dynamically creates a script in the body called which loads the graph. It works in all chrome and FF but not in IE8. meaning -when you click on on row it work's but the second row and on the script are not loading.. I don't even know how to debug it in IE8. can someone recommend a solution? :-)

the script that loads the other scripts is

$.post("shorts.server.php", $.param({
     val: stocknumber,
     id: id,
     name: stockname,
     group: stockgroup
 }), function (response) {
     //alert(response);
     // We dynamically add javascript headers
     var head = document.getElementsByTagName('body')[0];
     script = document.createElement('script');
     //dynamic_graph.js changes it's content by the current selected stock
     //see shorts.server.php for details
     script.src = 'jQuery/head/dynamic_graph.js';
     head.appendChild(script);
     script = document.createElement('script');
     //dynamic_graph.js changes it's content by the current selected stock
     //see shorts.server.php for details
     script.src = 'jQuery/head/dynamic_info.js';
     head.appendChild(script);
 });

Try to use jQuery.getScript :

function(response)
{
     $.getScript('jQuery/head/dynamic_graph.js');
     $.getScript('jQuery/head/dynamic_info.js');
}

In IE9 press F12 to run the debugger. In the debugger you can select the browser mode like : IE8. Use Jquery for all your DOM interactions and browser compatibility.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM