Labels

Saturday, October 27, 2012

What is JQuery?

 Q: - 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.
Q: - 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

$(document).ready(function(){
});
Over here $ sign can be replaced with "jQuery " keyword.
jQuery(document).ready(function(){
});
Q: - 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.
Q: - 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.
JQuery Interview Questions & Answers

Q: - 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
<script src="_scripts/jQuery-1.3.2.js" type="text/javascript"></script>
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.


Q: - There are 3 types of selectors in Jquery?

1. CSS Selector
2. XPath Selector
3. Custom Selector
Q: - Means of dollar Sign ($) in JQuery?

Dollar Sign is nothing but it's an alias for JQuery. Take a look at below jQuery code
$(document).ready(function(){
});
Over here $ sign can be replaced with "jQuery " keyword.
jQuery(document).ready(function(){
});

 Q: - What is the basic used of jQuery() function

->Establish code to be executed when the DOM is ready for manipulation.
->Help as a namespace for global utility functions.
->Create DOM elements from HTML markup.
->Select and wrap DOM elements to operate upon
Q: - which are basic selectors in jQuery (cross browser)?

->Element ID's
->CSS class name
->Tag name
->last but not the least DOM hierarchy.
Q: - How do you select an item using css class or ID and get the value by use of jquery

If an element of html like < div> , < p> or any tag have ID MyId and class used MyClass then we select the element by below jquery code
$('#MyId') for ID and for classs $('.MyClass') and for value
var myValue = $('#MyId').val(); // get the value in var Myvalue by id
Or for set the value in selected item
$('#MyId').val("print me"); // set the value of a form input
 Q: - what the use of $ symbol in Jquery

$ Symbol is just replacement of jquery means at the place of $ you may use jquery hence $ symbol is used for indication that this line used for jquery
Q: - How you will use Jquery means requirement needed for using jquery

Nothing more need to do just olny download jquery library(.js file) from any of the jquery site Download jquery and just linked with your html pages like all other javascript file
like below :
< script src="jquery.js" language="javascript" type="text/javascript">     Questions : 3 what the use of $ symbol in Jquery Answers : 3
$ Symbol is just replacement of jquery means at the place of $ you may use jquery hence $ symbol is used for indication that this line used for jquery

Q: - How do you select an item using css class or ID and get the value by use of jquery

If an element of html like < div> , < p> or any tag have ID MyId and class used MyClass then we select the element by below jquery code

$('#MyId') for ID and for classs $('.MyClass') and for value

var myValue = $('#MyId').val(); // get the value in var Myvalue by id
Or for set the value in selected item

$('#MyId').val("print me"); // set the value of a form input
Q: - >How to get the server response from an AJAX request using Jquery?

When invoking functions that have asynchronous behavior We must provide a callback function to capture the desired result. This is especially important with AJAX in the browser because when a remote request is made, it is indeterminate when the response will be received.
Below an example of making an AJAX call and alerting the response (or error):
 $.ajax({
     url: 'pcdsEmpRecords.php',
     success: function(response) {
        alert(response);
     },
     error: function(xhr) {
        alert('Error!  Status = ' + xhr.status);
     }
});


Q: - How do you update ajax response with id " resilts"

By using below code we can update div content where id 'results' with ajax response
 function updateStatus() {
     $.ajax({
            url: 'pcdsEmpRecords.php',
            success: function(response) {
             // update div id Results
             $('#results').html(response);
         }
     });
}


No comments:

Post a Comment