{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Ajax - Ajax Ajax uses instances of a special object...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Ajax Ajax uses instances of a special object XMLHttpRequest. We’ll defer for the moment how to get such an instance; suppose for now we have an instance ‘request’. Using ‘request’ to call the server request.open(“GET”, url , true); Prepares a request to the URL url using GET method to be processed asynchronously (false => synchronously) NOTE: URL must be from the same server! request.onreadystatechange = function; When server state changes, call the function function . Sometimes referred to as the “callback” function. request.send(null); Make the request to the server. Getting information back from the server request.readyState Contains integer 1-4: is 4 when server has finished processing the request request.responseText The contents of the URL url from the server.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
The autocompletion example The HTML file <form action="ordersubmit.php" method="post"> <table> <tr> <td>Your email address:</td> <td><input id="email" type="text" name="email" size="40" /></td> </tr> <tr> <td>Your shipping preference:</td>
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}