Also, for what purpose do you want to use AJAX ?
Let me assume some scenarios and tell you how AJAX will be of help.
a) When the user clicks on a button or link etc, you want to display some additional data in the page.
- Usually this is achieved by submiting the page, loading the data and displaying the page again with the data.
tags, then you can just say div.innerHTML=response.html etc.. Thus, what we achieved is some data is displayed to the user without submitting the whole page etc..
b) Validations - Assume a form where some data is entered, for eg. in the username textbox, user fills a username, and then user will continue to fill the rest of the form, meanwhile, during the onblur of the textbox, you can issue a asynchronous request to validate the username to check if such username already exists in the database, and if it exists, then immediately an alert could be displayed to the user accordingly.
c) Dynamic Data - for eg. You have two dropdowns 1) Country dropdown 2) Cities dropdown, thus when the user selects a country, then in the onchange event, you can issue a AJAX request to obtain all the cities of the country and populate the Cities dropdown.
refer to http://www.w3schools.com/ajax/ajax_intro.asp
to write the AJAX methods and related application specific callback methods.