AJAX Flashcards
AJAX stands for?
Asynchronous JavaScript and XML
What does AJAX do to improve the interactive experience in web apps?
• AJAX eliminates the need to reload a web page in
order to get new content from the server
• Removes the start-stop interaction where a
user has to wait for new pages to load.
• An intermediate layer (AJAX Engine) is introduced
into the communication chain between client and
server
List how AJAX works (7 steps)
- An event occurs in a web page (the page is loaded,
a button is clicked) - An XMLHttpRequest object is created by JavaScript
- The XMLHttpRequest object sends a request to a
web server - The server processes the request
- The server sends a response back to the web page
- The response is read by JavaScript
- Proper action (like page update) is performed by
JavaScript
What is a callback function?
A callback function is a function passed as a parameter to another function
What is the the keystone of AJAX
XmlHttpRequest Object
What is the XmlHttpRequest Object?
• The XHR is an object that is part of the DOM and
is built into most modern browsers
• It can communicate with the server by sending
HTTP requests (much like normal client/server
communication)
What is so good about the XmlHttpRequest Object?
• Independent of or <a> elements for
generating HTTP GET/POST requests
• It does not block script execution after sending
an HTTP request • As with content and style, JavaScript can now
programmatically manage HTTP communication</a>
what are the XmlHttpRequest Properties?
• readyState property
• onreadystatechange property
• status property
• responseXML property
responseText property
what are the XmlHttpRequest Methods?
• abort() – Cancels the current request • open(method, url, async, user, psw) – Specifies the request • method: the request type GET or POST
• url: the file location
• async: true (asynchronous) or false (synchronous) • user: optional user name
• psw: optional password
• send() – Sends the request to the server – Used for GET requests
• send(string) – Sends the request to the server. – Used for POST requests
• getAllResponseHeaders() – Returns all header information of a resource such
as length, server-type, content-type, last-modified
• getResponseHeader() – Returns specific header information such as “LastModified”
• setRequestHeader() – Adds a label/value pair to the header to be sent – Can be used with POST data to specify the data
you want to send with the send() method