Sometimes, it may happen that the CDN you have used to load the jQuery file is not available (it rarely happens, however anything is possible, isn‟t it?); in that case you should load your local jQuery file that is available on your server so that all jQuery related functionality still work on your page.
Write following lines of code
<script type="text/javascript" language="Javascript" src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.1.min.js"></script>
<script type='text/javascript'>//<![CDATA[
if (typeof jQuery == 'undefined') {
document.write(unescape("%3Cscript src='/Script/jquery-1.4.1.min.js' type='text/javascript' %3E%3C/script%3E"));
}//]]>
</script>
Replace bolded path with your own jQuery file path on the server. In the above code, first line tries to load the jQuery file from CDN, if browser could load the file successfully, “jQuery” variable will not be undefined and next script will not run otherwise next script will run that will write the script tag to load the jQuery file from your server.
0 comments:
Post a Comment