May 08, 2021 AJAX
To help you understand how AJAX works, we created a small AJAX application:
The AJAX application above contains a div and a button.
The div section is used to display information from the server. When a button is clicked, it is responsible for calling a function called loadXMLDoc():
<!DOCTYPE html>
<html> <body>
<div id="myDiv"><h2>Let AJAX change this text</h2></div>
<button type="button" onclick="loadXMLDoc()">Change Content</button>
</body>
</html>
Next, add a hashtag to the head section of the page. This loadXMLDoc() function is included in the label:
<head>
<script>
function loadXMLDoc()
{
.... AJAX script goes here ...
}
</script>
</head>
To create AJAX instances, you need to use server-side languages such as Servlet, JSP, PHP, ASP.Net, etc., and here we use JSP.
To create an instance of AJAX:
When you try the AJAX sample, there is no discontinuity and you can get a response very quickly, but when you try the standard GCI sample, you will have to wait for the response and your page will be refreshed.
In the next chapter, we'll continue to explain how AJAX works.