Is jQuery $ .getScript different in Firefox? It does not execute the script after loading, Chrome does everything

Following code

$.getScript("/js/dygraph-combined.js") .done(function(script, textStatus) { console.log(Dygraph); }) .fail(function(jqxhr, settings, exception) { console.error('it failed to load'); }); 

gives

Dygraph not defined

in Firefox 11.0 and

[Dygraph 1.2]

in Chrome 17.0.963.83.

So, it seems that the script loads in both browsers, but does not start in Firefox 11 ... Why? How can I behave as I should?

This script is Dygraph , and from his site it works in Firefox, but my graphs only work on Chrome, perhaps because jQuery $ .getScript can behave differently ...

+1
source share
2 answers

Try to do:

  $.getScript("http://dygraphs.com/dygraph-combined.js", function(script, textStatus) { setTimeout(function(){console.log(Dygraph);}, 0); }).fail(function(jqxhr, settings, exception) { console.error('it failed to load'); }); 
0
source

I had the same problem and in dygraph-combination.js he said: "This is not the file you are looking for." but the Jedi mind trick didnโ€™t work for me, I followed the link provided.
http://dygraphs.com/dygraph-combined.js

Now it works :)

0
source

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


All Articles