0

I am facing issues while using getScript() function, here is my script

$.getScript("script.js").done(function(script, textStatus,jqxhr) {    
   console.log(jqxhr.status);
})
.fail(function(jqxhr, settings, exception ) {
   console.log(jqxhr.status);
});

But i am getting the following error in the console..

Uncaught TypeError: Cannot read property 'done' of undefined, can you please suggest the solution. Actually i am using the getScript() function to check whether the server is up/down.

teo van kot
  • 12,350
  • 10
  • 38
  • 70
Siva
  • 3,297
  • 7
  • 29
  • 35
  • 1
    In what version of jQuery ? – adeneo Dec 26 '14 at 09:20
  • current jquery version is - v1.8.1 – Siva Dec 26 '14 at 09:25
  • 1
    That's strange, and when you do `console.log( $ === jQuery )` you get true, right? There is no way jQuery doesn't return a promise from `getScript` regardless of what the filename is etc. – adeneo Dec 26 '14 at 09:34
  • Works fine when testing -> **http://jsfiddle.net/c2n334nv/** – adeneo Dec 26 '14 at 09:36
  • @John, right before calling `$.getScript()` try logging `$.fn.jquery` and double-check the version number -- something on your page may be including another version of jQuery. – Frédéric Hamidi Dec 26 '14 at 09:38
  • Friends, i am really sorry about this, just now i have checked my jquery version number with jQuery.prototype.jquery, its showing "1.5.2" but in my project jquery.js file its showing v1.8.1. So is there any way to fix this in "1.5.2" ? – Siva Dec 26 '14 at 09:47
  • @John: You can have multiple version of jQuery in a single page which will resolve your issue. Check this question- http://stackoverflow.com/questions/1566595/can-i-use-multiple-versions-of-jquery-on-the-same-page – Mohit Pandey Dec 26 '14 at 10:15
  • i cannot use multiple versions in my project, but is there a way that we can override the old getScript function from the latest jQuery lib ? – Siva Dec 26 '14 at 18:49

0 Answers0