0

Using the following ajax, I am adding javascript code to the current page. On success it calls the sidenote() function from that javascript code.

This works in all modern browsers. However, in IE8 and FF22.0 (as I've noticed so far) it successfully imports the javascript, but does not call the function. Is there a work around for this or am I stuck on this one?

$.ajax({
    url:mpath+"scripts/stage.min.js",
    dataType:"script",
    success:function(){sidenote(1)}
})
Esoteric Screen Name
  • 6,082
  • 4
  • 29
  • 38
James
  • 69
  • 3
  • 12
  • 1
    What version of jQuery are you using? – Jason P Aug 08 '13 at 14:20
  • Oh, btw the function works fine. Even in the older browsers (when it's called again later on) – James Aug 08 '13 at 14:20
  • You may want to switch to using the `.done()` method. **update after your second comment** You may need to modify the `sidenote` function to include some delegation. – DevlshOne Aug 08 '13 at 14:21
  • 1.7 I'm probably stuck with it. It's in my company's joomla installation – James Aug 08 '13 at 14:21
  • I tried $.getScript() but couldnt get it to call the function at all. It always tried before the script could be added – James Aug 08 '13 at 14:33
  • Are you absolutely sure a js error isn't happening? just because the method in the script is being defined doesn't necessarily mean a js error isn't happening some time after said method. – Kevin B Aug 08 '13 at 14:34
  • Cant be certain about no js error. Annoyingly I cannot test older browsers at the moment because I cant install them on Win7 and the person in the office with XP that I periodically annoy so i can test older browser stuff is in a meeting for the rest of the day. – James Aug 08 '13 at 14:41

1 Answers1

0

TRY dataType : 'text' or dataType : 'xml' or dataType : 'json' or any other available response type

Bcoz IE is really not an intelligent browser, it doesn't assume the default value string.

Vaibs_Cool
  • 6,126
  • 5
  • 28
  • 61
  • you could also try dataType: "text script" so jquery will request it as text, then try to parse it as a script. – Kevin B Aug 08 '13 at 14:31
  • Unfortunately changing the dataType just results in all browsers not calling the function, possibly not calling it at all – James Aug 08 '13 at 14:35