AJAX
Terms
undefined, object
copy deck
- What handles requests and responses?
- Requests and responses are handled by the web browser, not directly by JavaScript code
- Clears first form in HTML document when body loads
- var request = new XMLHttpRequest();
- Creates a new object to talk HTTP to a web server (incompatible with IE)
- When events occur in a web page...
- Browser can run a function, and can give JS access to user-generated information in the page
- onFocus=""; triggered when?
- Event triggered when field is entered
- onBlur=""; triggered when?
- Event triggered when field is exited
- status
- The HTTP status code returned from the server
- responseText
- The data returned from the server in response to your request
- request.open("POST", url, true);
- Initializes an asynchronous request using POST
- readyState
- Number indicating what state the request is in: loading, in progress, finished processing, etc.
- request.onreadystatechange = updatePage;
- Set before calling request.send(null);, the browser runs this function (cannot have parenthesis) when server response received
- onChange="function();"
- Function run whenever user changes that particular field value
- What do asynchronous apps use to make requests?
- Asynchronous applications make requests using a JavaScript Object, not a form submit
- var phone=document.getElementByID("phone").value;
- Assigns the user-entered value in "phone" input to the variable "phone"
- onreadystatechange
- The function for the browser to run when the server responds to your request
- var url = "/servlet/GetMileageServlet";
- Creates a new variable and assigns it URL to a Java servlet
- The web browser gets a response to an asynchronous request, now what?
- When the web browser gets a response to an asynchronous request, it "calls back" the JavaScript with the server's response
- request.open("GET", url, false);
- Initializes a synchronous request using GET
- request.send(null);
- Not sending data in the request
- onChange=""; triggered when?
- Event triggered when field is chnaged