HTML and CSS Reference
In-Depth Information
And t he response would contain the tasks.html page, with the edit section populated. To
the user it would look like all the page content disappeared and then reappeared a second
or two later.
The alternative approach is AJAX (Asynchronous JavaScript and XML ) .
AJAX started life as an approach rather than a standard. In 1998 Microsoft implemented
a component called XMLHTTP. This allowed content to be dynamically requested from
the server and incorporated into the current page without a page refresh. This functionality
was later adopted by other web browsers as the XMLHttpRequest object. The XMLHt-
tpRequest is currently undergoing the standards process and is considered part of HTML5.
The XMLHttpRequest object allows a web page to send HTTP POST and GET requests
to the server, and receive data in response, but without refreshing the entire web page. For
instance, the request may return a fragment of the page that is then dynamically added to
the DOM.
It is worth examing the key aspects of AJAX:
• Asynchonous : AJAX requests are asynchronous because the main browser thread does
not block while the request is in flight. Responses to requests are handled with callbacks.
This means the user does not need to be aware that a request is in flight, and they can con-
tinue using the web application as though nothing was happening.
• JavaScript : The requests are performed using JavaScript objects, and the response is
made available as a JavaScript object.
• XML : Originally XMLHttpRequest utilized XML as the data exchange format. In fact,
XMLHttpRequest allows any data format to be used, and is now commonly used with
JSON rather than XML. It is also common to return HTML from an AJAX call, therefore
allowing it to be inserted directly into the DOM.
In fact, XMLHttpRequest is not dependent on HTTP either; it is supported with
other protocols such as FTP. In many respects XMLHttpRequest is the worst
named object in the history of JavaScript.
Essentially AJAX is a mechanism for asynchronously sending and/or receiving data from
a web server using JavaScript without a page refresh.
Search WWH ::

Custom Search