AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.



ajax-jquery: AJAX vs Jquery

Hello,
With the emergence of Jquery, AJAX queries become more easy.
Can we talk about the success of JQuery at the expense of AJAX?

ajax x 7
jquery x 12
Posted On : 2014-08-31 19:44:11.0
profile Ajili Ines - anyforum.in Ajili Ines
850
up-rate
4
down-rate

Answers


AJAX = Asynchronous JavaScript and XML:
--------------------------------------------------------------------------------
AJAX is all about loading data in the background and display it on the webpage, without reloading the whole page.

why JQuery:
--------------------------------------
jQuery is a lightweight JavaScript library i.e. "write less, do more". The purpose of jQuery is to make it much easier to use JavaScript. jQuery takes a lot of common tasks that require many lines of JavaScript code to accomplish, and wraps them into methods that you can call with a single line of code.

Many of the biggest companies on the Web use jQuery, such as:
Google
Microsoft
IBM
Netflix

The jQuery team knows all about cross-browser issues, and they have written this knowledge into the jQuery library. jQuery will run exactly the same in all major browsers, including Internet Explorer 6!

Now put a light on Jquery and AJAX:
------------------------------------------------------------------
jQuery provides several methods for AJAX functionality. With the jQuery AJAX methods, you request text, HTML, XML, or JSON from a remote server using both HTTP Get and HTTP Post -And you can load the external data directly into the selected HTML elements of your web page.

Writing regular AJAX code can be a bit tricky and typical, because different browsers have different syntax for AJAX implementation. This means that you will have to write extra code to test for different browsers. However, the jQuery team has taken care of this for us, so that we can write AJAX functionality with only one single line of code.


Example of AJAX with JQuery:
----------------------------------------------------------
Let´s see a simple example of making get AJAX request by JQuery library. and we don´t have to write code for all browser compatibility. Because in JQuery these issue internally is resolved. Suppose if we use AJAX without JQuery then we have to check that if there is internet Explorer then make the request by new ActiveXObject("Microsoft.XMLHTTP") and for other browsers we use new XMLHttpRequest(). so this is the extra code we have to write for browser compatibility. in JQuery all these kind of checking browser compatibility is internally resolved and it has many predefined function. just call then and get result. See below example:

JQuery-AJAX.html:
------------------------------------------

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.get("demo_test.jsp",function(data,status){
alert("Data: " + data + "\nStatus: " + status);
});
});
});
</script>
</head>
<body>

<button>Send an HTTP GET request to a page and get the result back</button>

</body>
</html>

Posted On : 2014-09-01 00:43:26
Satisfied : 2 Yes  0 No
profile Garima Gupta - anyforum.in Garima Gupta
596129560202
Reply This Thread
up-rate
5
down-rate

Thank you Garima for this rich response.

Posted On : 2014-09-01 00:46:10
Satisfied : 1 Yes  0 No
profile Ajili Ines - anyforum.in Ajili Ines
850
Reply This Thread
up-rate
2
down-rate
Comments
Your Welcome....
profile Garima Gupta - anyforum.in Garima Gupta
596  1295  60202
Posted On :2014-09-01 00:48:32.0
Leave a Comment



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in