Wednesday, January 16, 2008

XMLHttpRequest Properties

– 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
– HTTP Status returned from server: 200 = OK
– String version of data returned from server
– XML DOM document of data returned
– Status text returned from server

Methods available in XMLHttpRequest Object

open(“method”, “URL”)
open(“method”, “URL”, async, username, password)
– Assigns destination URL, method, etc.
– Sends request including postable string or DOM object data
– Terminates current request
– Returns headers (labels + values) as a string
– Returns value of a given header
– 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
• 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
• Core techniques are centered on asynchronous communication to the server without a page refresh

Thursday, January 3, 2008

Difference between echo() and print()


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.


echo() can take multiple parameters. But print() can take only one parameter.