Translated by Google Translate

What is AJAX and How to Use it With jQuery



Are you questioning What is AJAX, and How to Use it With jQuery? To answer the long question, we need to start it from the meaning of AJAX. No, it is not football club from Holland but AJAX is asynchronous JavaScript and XML. People use AJAX to load data from a server and then display it on the webpage without the need to reload the page. With AJAX, you will see only part of the website is changed while the other remain the same because the page is not refreshed. If you still confuse, you can open your Gmail and switch from “inbox” to “sent mail”. You will see the content is different but the page is the same. AJAX call is something you do behind the scene.

So, what is the benefit of AJAX?  
Minimize Bandwidth Usage
AJAX can work without reloading page, so you don't need to refresh and excedded your bandwidth usage.
Faster
Facebook is one from many website that using AJAX. When new notifications coming, it will show you the alarm or notification info in right top position of your facebook page, that's work by AJAX. You can imagine how it works without AJAX, you don't know if there are new notifications coming, you should refresh your facebook page to know that.
- User Friendly
You don't need to refresh the page if you want to see the changes.

Now that you know what AJAX is, we are half way. To complete the answer for What is AJAX, and How to Use it With jQuery we need to continue with it application with jQuery. If you wonder why jQuery, people love it because jQuery supports AJAX in fantastic way. Even more, you will find the implementation is very easy. One important thing is to tell the browser whether to catche AJAX or not, especially since different browsers will behave in different ways.

Here is how to do it :
$.ajaxSetup ({
cache: false
});
This is the example :
$.ajaxSetup ({
cache: false
});
var ajax_load = "<img src='img/load.gif' alt='loading...' />";
//  load() functions
var loadUrl = "ajax/load.php";
$("#load_basic").click(function(){
$("#result").html(ajax_load).load(loadUrl);
});
Example of $.ajax with success is:
$.ajax({url:'/'}).done(function(data){});
Now you have the answer for What is AJAX, and How to Use it With jQuery. This is the time to apply it and see what happen.




 

©2013 @namakuherman | Developed by Herman Creative Industry