Using $ .getScript to load d3.js

I am trying to load a d3js script using

$.getScript('http://d3js.org/d3.v2.js', function(data, textStatus) { console.log(textStatus); return true });

which correctly returns the success status.

I have already installed

 $.ajaxSetup({ cache: true, async: false }); 

so that the file fully loads before trying to use it.

But I get "TypeError: names.map (...). Join is not a function" in my console window.

Has anyone encountered such a situation? Is there anything special I need to do to download the file correctly?

I also tried

 var se = document.createElement('script'); se.type = "text/javascript"; se.src = "http://d3js.org/d3.v2.js"; document.getElementsByTagName('head')[0].appendChild(se); 

with the same results.

I have no problem with

 <script src="http://d3js.org/d3.v2.js"></script> 

but in this application this is not an option.

+4
source share
1 answer

Try getting started with the callback function

 $.getScript('http://d3js.org/d3.v2.js', function(data, textStatus) { //Start Using d3 functions here. return true }); 

You must be sure that the script is loaded ...

0
source

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


All Articles