Join Our Email Alerts-Subscribe
Important Note:Login & Check Your Email Inbox and Activate Confirmation Link


Enter Your Email :

Copyright Disclaimer:
Section 107 of the Copyright Act Fair Use Contents .
We are forwarding content link(s) from our website to content website & We are not serving any contents.
Main Source:Google.com.All the Content PDF link(s) is/are obtained from GoogleSearch
for the purpose of Education & Teaching Intention. Not for commercial purpose.
Technicalsymposium.com is not liable/responsible for any copyright issues.


Jquery Materials-Free Download



What is chaining in jQuery?

Ans: Chaining is one of the most powerful feature of jQuery. In jQuery, Chaining means to connect multiple functions, events on selectors. It makes your code short and easy to manage and it gives better performance. The chain starts from left to right. So left most will be called first and so on. 

$(document).ready(function(){

$('#dvContent').addClass('dummy');

$('#dvContent').css('color', 'red');

$('#dvContent').fadeIn('slow');

});

The above jQuery code sample can be re-written using chaining. See below. 

$(document).ready(function(){

$('#dvContent').addClass('dummy')

.css('color', 'red')

.fadeIn('slow'); 

});

Not only functions or methods, chaining also works with events in jQuery. 

Q58. How does caching helps and how to use caching in jQuery? 



Ans: Caching is an area which can give you awesome performance, if used properly and at the right place. While using jQuery, you should also think about caching. For example, if you are using any element in jQuery more than one time, then you must cache it. See below code. 

$("#myID").css("color", "red");

//Doing some other stuff......

$("#myID").text("Error occurred!");

Now in above jQuery code, the element with #myID is used twice but without caching. So both the times jQuery had to traverse through DOM and get the element. But if you have saved this in a variable then you just need to reference the variable. So the better way would be, 

var $myElement = $("#myID").css("color", "red");

//Doing some other stuff......

$myElement.text("Error occurred!");

So now in this case, jQuery won't need to traverse through the whole DOM tree when it is used second time. So in jQuery, Caching is like saving the jQuery selector in a variable. And using the variable reference when required instead of searching through DOM again. 

Q59. You get "jquery is not defined" or "$ is not defined" error. What could be the reason?

Ans: There could be many reasons for this. 

• You have forgot to include the reference of jQuery library and trying to access jQuery.

• You have include the reference of the jQuery file, but it is after your jQuery code.

• The order of the scripts is not correct. For example, if you are using any jQuery plugin and you have placed the reference of the plugin js before the jQuery library then you will face this error. 

Q60. How to write browser specific code using jQuery?

Ans: Using jQuery.browser property, we can write browser specific code. This property contains flags for the useragent, read from navigator.userAgent. This property was removed in jQuery 1.9. 

Q61. Can we use jQuery to make ajax request?

Ans: Yes. jQuery can be used for making ajax request.

Q62. What are various methods to make ajax request in jQuery?

Ans: Using below jQuery methods, you can make ajax calls. 

• load() : Load a piece of html into a container DOM

• $.getJSON(): Load JSON with GET method.

• $.getScript(): Load a JavaScript file.

• $.get(): Use to make a GET call and play extensively with the response.

• $.post(): Use to make a POST call and don't want to load the response to some container DOM.

• $.ajax(): Use this to do something on XHR failures, or to specify ajax options (e.g. cache: true) on the fly.

Q63. Is there any advantage of using $.ajax() for ajax call against $.get() or $.post()?

Ans: By using jQuery post()/ jQuery get(), you always trust the response from the server and you believe it is going to be successful all the time. Well, it is certainly not a good idea to trust the response. As there can be n number of reason which may lead to failure of response. 

Where jQuery.ajax() is jQuery's low-level AJAX implementation. $.get and $.post are higher-level abstractions that are often easier to understand and use, but don't offer as much functionality (such as error callbacks). 

Q64. What are deferred and promise object in jQuery?

Ans: Deferred and promise are part of jQuery since version 1.5 and they help in handling asynchronous functions like Ajax. 

Q65. Can we execute/run multiple Ajax request simultaneously in jQuery? If yes, then how?

Ans: Yes, it is possible to execute multiple Ajax request simultaneously or in parallel. Instead of waiting for first ajax request to complete and then issue the second request is time consuming. The better approach to speed up things would be to execute multiple ajax request simultaneously. 

Using jQuery .when() method which provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events. 

Q66. Can you call C# code-behind method using jQuery? If yes,then how?

Ans: Yes. We can call C# code-behind function via $.ajax. But for do that it is compulsory to mark the method as WebMethod. 

Q67. Which is the latest version of jQuery library?

Ans: The latest version (when this post is written) of jQuery is 1.10.2 or 2.0.3. jQuery 2.x has the same API as jQuery 1.x, but does not support Internet Explorer 6, 7, or 8. 

Q68. Does jQuery 2.0 supports IE?

Ans: No. jQuery 2.0 has no support for IE 6, IE 7 and IE 8. 

Q69. What are source maps in jQuery?

Ans: In case of jQuery, Source Map is nothing but mapping of minified version of jQuery against the un-minified version. Source map allows to debug minified version of jQuery library. Source map feature was release with jQuery 1.9. 

Q70. How to use migrate jQuery plugin?

Ans: with release of 1.9 version of jQuery, many deprecated methods were discarded and they are no longer available. But there are many sites in production which are still using these deprecated features and it's not possible to replace them overnight. So jQuery team provided with jQuery Migrate plugin that makes code written prior to 1.9 work with it. 

So to use old/deprecated features, all you need to do is to provide reference of jQuery Migrate Plugin. 

Q71. Is it possible to get value of multiple CSS properties in single statement?

Ans: Well, before jQuery 1.9 release it was not possible but one of the new feature of jQuery 1.9 was .css() multi-property getter. 

var propCollection = $("#dvBox").css([ "width", "height", "backgroundColor" ]);

In this case, the propCollection will be an array and it will look something like this. 

Hide Copy Code



width: "100px", 

height: "200px", 

backgroundColor: "#FF00FF" 

}

Q72. How do you stop the currently-running animation, remove all queued animations, and complete all animations for the matched elements? 

Ans: It can be done via calling .stop([clearQueue ] [, jumpToEnd ]) method and by passing both the parameters as true. 

Q73. What is finish method in jQuery?

Ans: The .finish() method stops all queued animations and places the element(s) in their final state. This method was introduced in jQuery 1.9. 

Q74. What is the difference between calling stop(true,true) and finish method?

Ans: The .finish() method is similar to .stop(true, true) in that it clears the queue and the current animation jumps to its end value. It differs, however, in that .finish() also causes the CSS property of all queued animations to jump to their end values, as well. 

Q75. Consider a scenario where things can be done easily with javascript, would you still prefer jQuery? 

Ans: No. If things can be done easily via CSS or JavaScript then You should not think about jQuery. Remember, jQuery library always comes with xx kilobyte size and there is no point of wasting bandwidth

Source: Contents are provided by Technicalsymposium Google Group Members. 
Disclaimer: All the above contents are provided by technicalsymposium.com Google Group members. 
Further, this content is not intended to be used for commercial purpose. Technicalsymposium.com is not liable/responsible for any copyright issues.


Download Technical Interview Materials PDF-Free Download

Technical Interview Questions and Answers Notes PDF
Placement Materials PDF-Free Download



Technicalsymposium.com-All Study Materials PDF-Free Download







Technicalsymposium.com-Free Live Support-Chat with Our Experts

Official Contact: +91-9245556793 (Whatsapp Message / SMS / Voice Call)


Our Expert team is ready to answer all your questions immediately-Feel free to speak in Tamil/English.

(Example:Events info/Lecture Notes/Off-Campus & All Jobs/Projects & All education information)

Working hrs (IST): (Morning: 10:00AM-3:00 PM) and (Evening:5:00 PM to 10:00 PM)

All Latest Question & Answer Page (FAQ)-Click here