• onreadystatechange
– Event handler that fires at each state change
– You implement your own function that handles this
• readyState – current status of request
– 0 = uninitialized
– 1 = loading
– 2 = loaded
– 3 = interactive (some data has been returned)
• This is broken in IE right now
– 4 = complete
• status
– HTTP Status returned from server: 200 = OK
• responseText
– String version of data returned from server
• responseXML
– XML DOM document of data returned
• statusText
– Status text returned from server
Wednesday, January 16, 2008
XMLHttpRequest Properties
Methods available in XMLHttpRequest Object
• open(“method”, “URL”)
• open(“method”, “URL”, async, username, password)
– Assigns destination URL, method, etc.
• send(content)
– Sends request including postable string or DOM object data
• abort()
– Terminates current request
• getAllResponseHeaders()
– Returns headers (labels + values) as a string
• getResponseHeader(“header”)
– Returns value of a given header
• setRequestHeader(“label”,”value”)
– Sets Request Headers before sending
why is AJAX so hot—NOW?
• Demand for richer applications is growing
– Broadband means we can—and want to—do more
• It has a name
– Think LAMP—helped solidify the thoughts/techniques in people’s
minds
• Recent Google applications have sparked people’s imagination
– Google gmail, Google suggests, Google Maps
• People are thinking of building APPLICATIONS…not just sites
• The Tipping Point
– All of this has made rich internet apps reach its tipping point—
where adoption spreads rapidly and dramatically
Definition - AJAX
Asynchronous Javascript and XML
• AJAX is not a new technology
– Google calls their technique: Javascript
– Also known as XMLHTTP technique
– In use since at least 1997
• A bundle of techniques
– XML data interchange only
– Passing Javascript methods to client
– DHTML widgets
– XML & XSLTs
• Core techniques are centered on asynchronous communication to the server without a page refresh
PHP define AJAX
Thursday, January 3, 2008
Difference between echo() and print()
speed:
echo() is faster than print(). Because print() behave like a function. So it set a return value. But echo() doesn't set a return value.
Parameter:
echo() can take multiple parameters. But print() can take only one parameter.