FAQ Database Discussion Community


jQuery.getScript() fails to load function

jquery,function,undefined,getscript
I am trying to load a script with a function like: $.getScript('/js/mymy.js').done(function(){ if(readCookie('my_cookie', 'yes')){ /* do sth here */ } }); or $.getScript('/js/mymy.js',function(){ if(readCookie('my_cookie', 'yes')){ /* do sth here */ } }); where "readCookie" is defined in mymy.js but i get an error "readCookie" is not defined... Here 1 &...

Is there a default timeout for jQuery`s getScript method? [duplicate]

javascript,jquery,getscript
This question already has an answer here: JQuery ajax call default timeout value 3 answers I am using jQuery's getScript() method to load some third part js library, I am wondering whether there's a default time out value for this method. I don't really believe getScript will keep waiting...

How to initialize jQuery plugin loaded using $.getScript

jquery,plugins,magnific-popup,getscript
I am checking if a jQuery plugin (magnific popup) script is already loaded into the DOM, if it isn't then I want to load it: if(typeof $.fn.magnificPopup !== 'undefined'){ console.log('Plugin exists'); }else{ $.getScript('vendor/jquery.magnific-popup.min.js', function(){ console.log('Script loaded.'); }); } Now normally I would initialize magnific popup like this: $('.gallery-img').magnificPopup({ type: 'image',...

jQuery - Executing another javascript file

jquery,getscript
In jQuery, how do I execute another javascript file? I have the following files: folder/page.html folder/objects/control.js folder/objects/test.js In the page.html, I have the following code: <script src="objects/control.js" type="text/javascript"></script> In the control.js, I have the following code: var url = "objects/test.js"; $.getScript( url, function() { alert("test"); }); In the test.js, I...