1

The 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');
  });

yields

Dygraph is not defined

in Firefox 11.0, and

[Dygraph 1.2]

on Chrome 17.0.963.83.

So it seems that the script loads on both browsers but doesn't get executed in Firefox 11... Why would that be ? How do I get this behaving like it should ?

This script is Dygraph and from it's website it works on Firefox, but my graphs only work on Chrome possibly because jQuery's $.getScript might be behaving differently...

João Pinto Jerónimo
  • 9,586
  • 15
  • 62
  • 86
  • What URL are you testing at? It could be a relatively absolute path issue. – Ry- Mar 23 '12 at 02:37
  • I'm testing at /#!/admin... But /js/dygraph-combined.js actually exists and there's no 404 error in the logs. It does actually load the file, I can see it in Firefox's console with Ctrl+Shift+K... I think it's just not executing the script... If I put inside "console.log(script)" inside the callback of .done, it will print out the code of that script, both in Chrome and Firefox... – João Pinto Jerónimo Mar 23 '12 at 02:41
  • 1
    Can you post dygraph-combined.js? – Adam Merrifield Mar 23 '12 at 02:54
  • @Adam here it is: http://dygraphs.com/dygraph-combined.js – João Pinto Jerónimo Mar 23 '12 at 02:56
  • @JoãoPintoJerónimo - Did you figure this out? I'm having the same issue. – rd42 May 15 '12 at 21:18

2 Answers2

0

I had the same issue and in the dygraph-combined.js it said "This is not the file you are looking for". but the jedi mind trick didn't work on me, I followed the link provided.
http://dygraphs.com/dygraph-combined.js

Now it works :)

rd42
  • 3,584
  • 15
  • 56
  • 68
0

Try doing:

    $.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');
    });
Adam Merrifield
  • 10,307
  • 4
  • 41
  • 58
  • With 0 it yields the same result as before, but if I wait 700ms it does display the graph... is it weird that it works so fine in Chrome but not in firefox ? – João Pinto Jerónimo Mar 23 '12 at 03:19
  • Update: But only because I was loading from http://dygraphs.com/dygraph-combined.js.... Now that I'm loading from the same server, with /js/dygraph-combined.js that I swear it exists and doesn't give a 404 error, it just won't happen... – João Pinto Jerónimo Mar 23 '12 at 03:25
  • I'm not sure what the problem would be, it works fine for me in ff and chrome, maybe it just needs to propagate throughout the cache before? But i means as long as it works like that lol – Adam Merrifield Mar 23 '12 at 03:25
  • @JoãoPintoJerónimo Are you sure that the path is correct? and can you post a link to the one on your sever? – Adam Merrifield Mar 23 '12 at 03:28
  • It works fine for me in Firefox and Chrome but in Dygraphs' website, most probably because they're not using $.getScript to load the library. Yes, I'm pretty sure the path is correct, as I said I see the file being loaded in the console... Well I can give you a link but you'd have to register and then login because it's in an administration page... http://crowdprocess.com and when you register, log in to http://crowdprocess.com/#!/admin – João Pinto Jerónimo Mar 23 '12 at 03:48
  • For what it's worth, you shouldn't source directly from dygraphs.com as that file tends to change frequently and without warning. – danvk Mar 23 '12 at 21:17