Will Apache running on port 8080 prevent dynamically loaded scripts in JavaScript?

If a good prototype of PHP / HTML / JS worked on my personal Linode, he tried to drop it into a working machine.

The page adds the script tag dynamically using some JavaScript. This is a bunch of Google charts that are updated based on different time series. This code looks something like this:

// jQuery $.post to send the beginning and end timestamps
$.post("channel_functions.php", data_to_post, function(data){
   // the data that returned is the javascript I want to load
   var script = document.createElement('script');
   var head= document.getElementsByTagName('head')[0];
   var script= document.createElement('script');
   var text = document.createTextNode(data);
   script.type= 'text/javascript';
   script.id = 'chart_data';
   script.appendChild(text);
   // Adding script tag to page
   head.appendChild(script);
   // Call the function I know were present in the script tag
   loadTheCharts();
});

function loadTheCharts() {
   // These are the functions that were loaded dynamically
   // By this point the script tag is supposed be loaded, added and eval'd
   function1();
   function2();
}

Function1 () and function2 () do not exist until they are added to dom, but I do not call loadTheCharts () until $ .post is run, so this does not seem to be a problem.

PHP-, , JavaScript , O'Reilly. dev, , .

, , , 8080, 192.168.blah.blah: 8080/index.php nicedomain.com/index.php.

, dom, - " ", Firebug , "function2() - undefined", , script .

: , , : 8080, , , , function2(), Linode Apache 8080?

+3
2

jQuery javascript :

$.post("channel_functions.php", data_to_post, 
       function (data, textStatus, xhr) {loadTheCharts()}, 
       'script');

a dataType "script" POST GET, .

eval , eval-ed , eval. jQuery.globalEval. - :

$.post("channel_functions.php", data_to_post, 
       function (data, textStatus, xhr) {
           /* data might have errors, which will cause an exception.
              We'll let the default exception handler catch & log it.
            */
           $.globalEval(data);
           loadTheCharts();
       });
+2

? script node.

+1

Source: https://habr.com/ru/post/1741344/


All Articles