.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal

Home >> Interview Question >> JQuery >> Post New Question Subscribe to Interview Questions

How to load jQuery locally when CDN fails?

Posted By :abhays     Posted Date :August 15, 2014    Points :40   Category :JQuery 
It is a good approach to always use CDN but sometimes what if the CDN is down (rare possibility though) but you never know in this world as anything can happen.

Below given jQuery code checks whether jQuery is loaded from Google CDN or not, if not then it references the jQuery.js file from your folder.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript"> if (typeof jQuery == 'undefined') { document.write(unescape("%3Cscript src='Scripts/jquery.1.9.1.min.js' type='text/javascript'%3E%3C/script%3E")); } </script>
It first loads the jQuery from Google CDN and then check the jQuery object. If jQuery is not loaded successfully then it will references the jQuery.js file from hard drive location. In this example, the jQuery.js is loaded from Scripts folder.

You can also find related Interview Question to How to load jQuery locally when CDN fails?  below: 

How to load jQuery from CDN?

Below is the code to load jQuery from all Three CDNs.

1.Code to load jQuery Framework from Google CDN

2.Code to load jQuery Framework from Microsoft CDN

3.Code to load jQuery Framework from jQuery Site(EdgeCast CDN)


What is the use of jquery load() method

The jQuery load() method is a powerful AJAX method.
The load() method loads data from a server and puts the returned data into the selected element without reload the complate page.
Ex:The following example loads the content of the file "test.txt" into a specific
$("#div1").load("test.txt"); (More...)

List the various stages of Page-Load lifecycle.

o Init()
o Load()
o PreRender()
o Unload() (More...)

What is JQuery?

JQuery is Java Script library or Java Script Framework which helps in how to traverse HTML documents, do some cool animations, and add Ajax interaction to any web page. It mainly helps programmer to reduce lines of code as huge code written in Java Script, can be done easily with JQuery in few lines. (More...)

What does dollar Sign ($) means in JQuery?

Dollar Sign is nothing but it's an alias for JQuery. Take a look at below jQuery code



Over here $ sign can be replaced with "jQuery " keyword.


}); (More...)

How is body onload() function is different from document.ready() function used in jQuery?

Document.ready() function is different from body onload() function because off 2 reasons.

1. We can have more than one document.ready() function in a page where we can have only one onload function.
2. Document.ready() function is called as soon as DOM is loaded where body.onload() function is called when everything gets loaded on the page that includes DOM, images and all associated resources of the page. (More...)

What are the steps you need to follow to use jQuery in ASP.Net project?

It's really simple. One just need to add reference of javascript file(.js). Go to Jquery.com and download the latest version of jQuery. When download is completed, there is a "jQuery-1.3.2.js" in the folder. Include this file

and you good to go now for JQuery.

Note : 1.3.2 denotes the library version.. It can be vary depending upon the version of Jquery you download. (More...)

What methods are fired during the page load?






Unload() (More...)

What methods are fired during the page load?

Init() - when the pageis instantiated,
Load() - when the page is loaded into server memory,
PreRender() - the brief moment before the page is displayed to the user asHTML,
Unload() - when page finishes loading.


There are 3 types of selectors in Jquery?

1. CSS Selector
2. XPath Selector
3. Custom Selector (More...)

Name some of the methods of JQuery used to provide effects?

1. Show()
2. Hide()
3. Toggle()
4. FadeIn()
5. FadeOut() (More...)

In the page load event I assigned DropDownList's DataSource property to a valid list. On the submit button click.. the same DataSource property is coming as null. Why?

As ViewState is not storing the DataSource property.

We have to use Items property of DropDownList to get the items back. (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend