We help IT Professionals succeed at work.
Get Started

Load external script within Ext JS 4

Last Modified: 2015-05-02
Within Ext JS 4, I need to load D3 API. I am using the below code

	loadScript: function(callback, scope) {		console.log('5) loadScript called');      
		Ext.Loader.injectScriptElement('http://d3js.org/d3.v3.js', onLoad, onError);
	    console.log('D3 script loaded ');

    onError : function() {
		console.log('On Error');
	onLoad : function() {
		console.log('On Load');
		d3.select('body').append('div').style('position', 'absolute').style('padding', '0 10px').style('background', 'red').style('opacity', 0);

Open in new window

However, in browser console, I get the below error -

Uncaught ReferenceError: onLoad is not defined

Can someone please help me rectify the above code?

Thank you.
Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE