If you are the web developer and you are not using ajax functionalities in your web application then you are missing one of the cool features of web technology.
What is the ajax ?
Ajax is the asynchronous JavaScript with xml. which is used for doing the asynchronous communication between client and server. It will avoid unnecessary round trip between client and server so it will give good performance as compare to old technology.
Ajax is one of the important concept of jquery library. Using ajax in jquery we can create very interactive and light weight web web application.
Jquery library provide the 5 methods for doing the ajax functionalities. These as given below
1. Load
2. getjson
3. GET
4. POST
5. Ajax
In this post, i will include some of the important methods which are being used frequently
Load:
Load method is used to load the data from a server and put the data in the given selected area.
Step 1: Create one notepad text file and keep some dummy text data on it. I have created Test.txt and kept in the parent folder.
Step 2: Write the code for calling the “Test.txt” file in given Div as given below
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="../../Scripts/jquery.min.js"></script> <style> .bckColor { background-color:silver; } </style> <script> $(function () { $("button").click(function () { $("#div1").load("Test.txt"); }); }); </script> </head> <body> <fieldset> <legend> Sample code for calling load method in Jquery. </legend> <div id="div1"></div> <button>Click Here</button> </fieldset> </body> </html> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> </body> </html>
Summary :
In the above example we show that Load method is used to load the notepad text document in the given div area in asynchronous way.
One thought on “Ajax in Jquery (Part 15)”