AJAX
AJAX
• Ajax uses XHTML for content, CSS for presentation, along with
Document Object Model and JavaScript for dynamic content display.
• Conventional web applications transmit information to and from the
sever using synchronous requests. It means you fill out a form, hit
submit, and get directed to a new page with new information from
the server.
• With AJAX, when you hit submit, JavaScript will make a request to
the server, interpret the results, and update the current screen. In
the purest sense, the user would never know that anything was
even transmitted to the server.
• XML is commonly used as the format for receiving server data,
although any format, including plain text, can be used.
• AJAX is a web browser technology independent of web server
software.
• A user can continue to use the application while the client program
requests information from the server in the background.
• Intuitive and natural user interaction. Clicking is not required,
mouse movement is a sufficient event trigger.
• Data-driven as opposed to page-driven.
AJAX is the most viable Rich Internet Application (RIA) technology so far.
It is getting tremendous industry momentum and several tool kit and
frameworks are emerging. But at the same time, AJAX has browser
incompatibility and it is supported by JavaScript, which is hard to
maintain and debug.
The classic web application model works like this:Most user actions in the
interface trigger an HTTP request back to a web server. The server does
some processing — retrieving data, crunching numbers, talking to various
legacy systems — and then returns an HTML page to the client. It’s a
model adapted from the Web’s original use as a hypertext medium, but as
fans of The Elements of User Experience know, what makes the Web good
for hypertext doesn’t necessarily make it good for software applications.
Figure 1: The traditional model for web applications (left) compared to the
Ajax model (right).
Ho w Aja x is D iffe r e nt
Syntax:
At first, you have to invoke the XMLHttpRequest() method as shown
below.
var variable_name = new XMLHttpRequest();
variable_name.send();
The XMLHttpRequest object has different functions and properties that are
listed below.
• HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
"width=device-width, initial-scale=1.0">
<style>
#container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
</style>
</head>
<body>
<div id="container">
<h1>Hey hello,</h1>
<h3>Welcome to web technology</h3>
Update Text
</button>
</div>
<script>
function stateChange() {
state.onload = function () {
document.getElementById("container")
.innerHTML = state.getAllResponseHeaders();
state.send();
</script>
</body>
</html>