HELLO WORLD APPLICATION IN AJAX FRAMEWORK

Introduction
Ajax is of the most important technologies for the development of highly interactive web application and due to its features it has become extremely popular these days.

Asynchronous JavaScript and XML or Ajax for short is new web development technique used for the development of most interactive website. Ajax helps you in making your web application more interactive by retrieving small amount of data from web server and then showing it on your application. You can do all these things without refreshing your page. Usually in all the web applications, the user enters the data into the form and then clicks on the submit button to submit the request to the server. Server processes the request and returns the view in new page ( by reloading the whole page). This process is inefficient, time consuming, and a little frustrating for you user if the only the small amount of data exchange is required. For example in an user registration form, this can be frustrating thing for the user, as whole page is reloaded only to check the availability of the user name. Ajax will help in making your application more interactive. With the help of Ajax you can tune your application to check the availability of the user name without refreshing the whole page.

Understanding the technology behind Ajax
Ajax is not a single technology, but it is a combination of many technologies. These technologies are supported by modern web browsers. Following are techniques used in the Ajax applications. y JavaScript: JavaScript is used to make a request to the web server. Once the response is returned by the webserver, more JavaScript can be used to update the current page. DHTML and CSS is used to show the output to the user. JavaScript is used very heavily to provide teh dynamic behavior to the application. Asynchronous Call to the Server: Most of the Ajax application used the XMLHttpRequest object to send the request to the web server. These calls are Asynchronous and there is no need to wait for the response to come back. User can do the normal work without any problem. XML: XML may be used to receive the data returned from the web server. JavaScript can be used to process the XML data returned from the web server easily.

y

y

JavaScript request call back functions is used to update the browser. Most traditional web applications have clumsier and difficult to use interfaces compared to desktop ones. DHTML and css is used to update the browser display. the server to respond. web-based applications that look and works like a desktop application Ajax is easy to learn. and the client only displaying static content. y y Benefits of Ajax Ajax is new very promising technology. Ajax is based on JavaScript and existing technologies like XML. CSS.Ajax engine receives the response from the server. etc. which requires data to be sent to the server. The biggest drawback with this system is that all interaction must pass through the server. DHTML. the Ajax engine is initialized and loaded. The primary difference between a RIA and traditional web applications is the amount and quality of interaction . and the page to be reloaded on the client with the response. Then it calls the JavaScript call back functions * Browser (View) update . Initialization of Ajax engine: When the page is initially loaded. Here are the benefits of using Ajax: y Ajax can be used for creating rich. Traditional web applications centered all activity around a client-server architecture with all processing done on the server. The Ajax engine operates asynchronously while sending the request to the server and receiving the response from server. RIA's transfer the processing necessary for the user interface to the web client but keep the bulk of the data back on the application server.Working of AJAX When user first visits the page. Event Processing Loop: * Browser event may instruct the Ajax engine to send request to server and receive the response data * Server response . The Ajax engine can also be set to continuously refresh the page content without refreshing the whole page. its very easy to learn Ajax Ajax can be used to develop web applications that can update the page data continuously without refreshing the whole page y y Rich Internet Applications According to Wikipedia Rich Internet Applications (RIA) are web applications that have the features and functionality of traditional desktop applications. the Ajax engine is also initialized. So. From that point of time user interacts with Ajax engine to interact with the web server. which has become extremely popular these days. Ajax life cycle within the web browser can be divided into following stages: y User Visit to the page: User visits the URL by typing URL in browser or clicking a link from some other page.

b) Wider variety of controls e. } else if(window. Some of the features and benefits delivered by RIA's are listed below a) Allows feedback.XMLHTTP"). Adobe Flash and Flex. Efforts are being made to make AJAX work with the other mentioned technologies. Source Code HelloWorld.Python.Ruby and other backend technologies.PHP.ActiveXObject) { return new ActiveXObject("Microsoft. } else { alert("Betterupgrade to Firefox. spinners etc.Perl. windows. confirmation and errors messages to be displayed on same page/view.between the user and the interface. Another benefit of RIAs is that data can be cached in the client.g."). c) No installation.html <html> <head> <title>The Hello World of AJAX</title> <script language="JavaScript" type="text/javascript"> function getXmlHttpRequestObject() { if (window. feedback and overall user experience. allowing a vastly more responsive user interface and fewer round trips to the server. sliders. Adobe Systems has released libraries to help developers bridge Adobe Flash and Flex technology with AJAX. just an AJAX enabled browser required d) Higher immunity to viruses and piracy. better error management. and AJAX. e) Reduced load on server resources as processing is distributes over server and client f) Lowered application development and deployment costs g) Reduction in network traffic due to more intelligent client and selective data request The most common technologies used for building RIA's are Java applets and web start.. Similarly libraries are available to integrate AJAX with Java.XMLHttpRequest) { return new XMLHttpRequest(). tabs. An RIA can use a wider range of controls to improve users¶ interaction allowing efficient interactions. } . date pickers.NET.

readyState == 0) { receiveReq.readyState == 4 || receiveReq.responseText. receiveReq.onreadystatechange = handleSayHello.send(null). } } </script> </head> <body> <a href="javascript:sayHello().} var receiveReq = getXmlHttpRequestObject().html'.readyState == 4) { document. 'SayHello.innerHTML = receiveReq.html hello. } } function handleSayHello() { if (receiveReq. world .open("GET".getElementById('span_result'). true). receiveReq. function sayHello() { if (receiveReq.">Say Hello</a><br /><span id="span_result"></span> </body> </html> SayHello.

Output: .

Sign up to vote on this title
UsefulNot useful