I\'m using the following bit of script to load another one:
$.getScript(\"CAGScript.js\", function () {
try {
CAGinit();
} catch(err) {
If the file is held on the same domain then jQuery will use XHR to retrieve its contents and then will globally "eval" it. This should work fine but if you're having problems then I'd suggest using the alternative method of injecting a script tag. Unfortunately, jQuery doesn't expose this functionality so you'll have to do it yourself:
var script = jQuery('').attr('src', 'CAGSCript.js').appendTo('head');
var timer = setInterval( function(){
if (window.CAGInit !== undefined) {
clearInterval(timer);
script.remove();
// Do your stuff:
CAGInit();
}
}, 200);
It'd be best to abstract this to a function; the above is just an example...