3 important ASP.NET jquery CDN Interview questions with answers
- By Shiv Prasad Koirala in ASP.NET
- Oct 21st, 2013
- 5451
- 0
What is CDN (Content delivery network)?
So if a user is from India, the Indian CDN server will serve request for Indian users. This leads to faster delivery and good backup in case there are issues.
For Jquery files which are the popular CDN's?
If you want to reference google CDN Jquery files you can use the below script.
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
< SPAN>script>
If you want to use Microsoft CDN you can use the below javascript.
<script type="text/javascript"
src="http://ajax.microsoft.com/ajax/jquery/jquery-1.9.1.min.js">
< SPAN>script>
How can we reference local Jquery files if CDN fails ?
Many times it's possible that Microsoft and google servers can go down for some time. So in those situations you would like your page to reference jquery files from local server.
So to implement a CDN fallback is a two-step process :-
First reference the CDN jquery. In the below code you can see we have reference Microsoft CDN jquery file.
http://ajax.microsoft.com/ajax/jquery/jquery-1.9.1.min.js">< SPAN>script>
Now if Microsoft CDN is down then the Jquery value will be "undefined". So you can see in the below code we are checking if the Jquery is having "undefined" value then do a document write and reference your local Jquery files.
if (typeof jQuery == 'undefined')
document.write(unescape("%3Cscript src='Scripts/jquery.1.9.1.min.js' type='text/javascript'%3E%3C/script%3E"));
}
Below is the full code for the same.
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.9.1.min.js">< SPAN>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"));
}
< SPAN>script>
All the above three ASP.NET JqueryInterview questions with answers are provided by questpond.com
The above questions are taken from the famous .NET Interview question book published by Bpbpublications , you can know more about the book from http://www.flipkart.com/net-interview-questions-6th/p/itmdyuqzdqx8cvqx
Shiv Prasad Koirala
Visit us @ www.questpond.com or call us at 022-66752917... read more