1 / 14

Lab 13: AJAX

Still working on them, should be done in the next couple of days. Final project presentations will be on Dec. 2nd. Questions? Learn about AJAX, web servers, AJAX syntax, GET vs POST, AJAX status codes, and more.

sconnie
Download Presentation

Lab 13: AJAX

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab 13: AJAX User Interface Lab: GUI Lab Nov 18th, 2014

  2. Project 4 Grades • Still working on them, should be done in the next couple days.

  3. Final Project • All presentations will be on Dec 2nd • I will post presentation details today • Questions?

  4. Web Servers • Serve content to webpages • Generally where the interesting content comes from

  5. AJAX • Asynchronous JavaScript and XML • The protocol webpages use to talk to servers • Not actually a new language just a way of programming

  6. AJAX Syntax varreq = new XMLHttpRequest(); //for IE5 and 6 varreq = new ActiveXObject(“Microsoft.XMLHTTP");

  7. AJAX Syntax req.open(“GET”, “someURL”, true); req.send(); req.open(“POST”, “someURL”, true); req.send();

  8. GET vs POST • GET • Generally intended for pulling small information • Cannot send very much information • Faster • POST • Generally meant for updating server data • Unlimited information limit • Slower

  9. AJAX Syntax req.onreadystatechange = function() { if(req.readyState == 4 && req.httpStatus == 200) { //successful } }

  10. AJAX Status Codes • req.readyState • 0: request not initialized • 1: server connection established • 2: request received • 3: processing request • 4: request finished and response is ready • req.status • 200: “OK” • 404: “Page not found”

  11. AJAX async • true • request runs and will call onreadystatechange when its status changes • default status • false • will halt javascript execution until the request is finished • rarely used and normally only for short things

  12. Reading AJAX result • req.responseText - the response as straight text in a string • req.responseXML – a structured object with properties but only works if the response was formatted in XML

  13. Sending Variables in AJAX url.asp?attr1=var1&attr2=var2

  14. More on AJAX • see here: http://www.w3schools.com/ajax/default.asp

More Related