4

I am trying to load the d3js script using

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

which is correctly returning the "success" status.

I have already set

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

so that the file is completely loaded before trying to use it.

But I am getting "TypeError: names.map(...).join is not a function" in my console window.

Has anyone encountered this situation? Is there something special that I need to do to get the file to load 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, it is not an option.

2
  • I can't reproduce the error. Try doing this : Open your browser JS console, paste in the first code snippet and execute it. In my browsers (FF & Chrome) this causes no error messages. If the same happens in your case, it might be that the error is the result of a problem somewhere else in your code. Commented Oct 30, 2012 at 16:45
  • 1
    Can you create a jsfiddle for this? I can't recreate this either - see jsfiddle.net/mccannf/EhESp/4 Commented Oct 30, 2012 at 21:42

1 Answer 1

1

Try to start working in the callback function

$.getScript('http://d3js.org/d3.v2.js', function(data, textStatus) { 

//Start Using d3 functions here.

 return true 

});

You need to be sure that the script was loaded...

Sign up to request clarification or add additional context in comments.

1 Comment

Worked for me. I have another version of d3 loaded on the same page, so would you know how to assign this version of d3 the name d3v5?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.