dotneter
dotneter

Reputation: 1689

How check if ajax.googleapis.com blocked and use my hosting of jquery?

I use http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js but some compaty may block this site, so in this case I want to use my local version on jquery /JavaScripts/jquery.min.js. How can I do it?

Upvotes: 3

Views: 1903

Answers (1)

jAndy
jAndy

Reputation: 236162

if(typeof(jQuery) === 'undefined'){             
    var scr =   document.createElement('script');
                scr.setAttribute('type', 'text/javascript');
                scr.setAttribute('src', 'http://yourdomain/jquery.min.js');

    document.getElementsByTagName('head')[0].appendChild(scr);
    setTimeout(function(){
        // $(document).ready(); here for instance
    }, 3000);

Upvotes: 1

Related Questions