I am trying to load a script with a function like:
$.getScript(\'/js/mymy.js\').done(function(){
if(readCookie(\'my_cookie\', \'yes\')){
/* do sth h
readCookie
is undefined because readCookie
is not global; it is visible only within the document.ready
function scope in mymy.js
.
Make the function global by removing the document.ready
wrapper.
From the docs:
The callback is fired once the script has been loaded but not necessarily executed.
In other words, you cannot rely on the success
function to be called explicitly after the loaded script is executed, e.g., its functions put into the global scope.
After your edit (which IMO should have been what you posted first) you actually have two issues; as written it's scoped only inside JQ's DOM-ready function.)