Lab 13 AJAX User Interface Lab GUI Lab
Lab 13: AJAX User Interface Lab: GUI Lab Nov 18 th, 2014
Project 4 Grades • Still working on them, should be done in the next couple days.
Final Project • All presentations will be on Dec 2 nd • I will post presentation details today • Questions?
Web Servers • Serve content to webpages • Generally where the interesting content comes from
AJAX • Asynchronous Java. Script and XML • The protocol webpages use to talk to servers • Not actually a new language just a way of programming
AJAX Syntax var req = new XMLHttp. Request(); //for IE 5 and 6 var req = new Active. XObject(“Microsoft. XMLHTTP");
AJAX Syntax req. open(“GET”, “some. URL”, true); req. send(); req. open(“POST”, “some. URL”, true); req. send();
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
AJAX Syntax req. onreadystatechange = function() { if(req. ready. State == 4 && req. http. Status == 200) { //successful } }
AJAX Status Codes • req. ready. State – 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”
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
Reading AJAX result • req. response. Text - the response as straight text in a string • req. response. XML – a structured object with properties but only works if the response was formatted in XML
Sending Variables in AJAX url. asp? attr 1=var 1&attr 2=var 2
More on AJAX • see here: http: //www. w 3 schools. com/ajax/default. asp
- Slides: 14