Beruflich Dokumente
Kultur Dokumente
So what is Ajax ?
A programming language no A new technology not exactly So what else ?
AJAX is not a new programming language but a new way to use the existing standards
AJAX is the art of exchanging data with a server, and update parts of a web page - without reloading the whole page. In an ajax web application, these are two variations from the traditional web interaction. First, the communications from the browser to the server is asynchronous; that is, the browser need not wait for the server to respond, the browser user can continue whatever he or she was doing while the server finds and transmit the requested document and the browser renders the new document. Second, the document provided by the server usually is only a relatively small part of the displayed document, and therefore it takes less time to be transmitted and rendered. These two changes can result in much faster interaction between the browser and the server.
Technologies Used
AJAX uses:
Javascript (for altering the page) XML (for information exchange) ASP or JSP (server side)
Google Suggest
Google Map
Simple Processing
AJAX is based on Javascript, and the main functionality is to access the web server inside the Javascript code. We access to the server using special objects; we send data and retrieve data. When user initiates an event, a javascript function is called which accesses server using the objects. The received information is shown to the user by means of the Javascripts functions.
Contd
onreadystatechange:
Property that takes a function as value that is invoked when the readystatechange event is dispatched.
Methods:
open(mode,url,boolean) mode: type of request, GET or POST url: the location of the file, with path. boolean: true(asynchronous)/false(synchronous) optionally, a login and password may be added to arguments. Send(string): Null for a GET command.
400
404 500 505
Contd..
try { xhr = new ActiveXObject("Microsoft.XMLHTTP"); // Trying Internet Explorer } catch(e) // Failed { xhr = new XMLHttpRequest(); // Other browsers. }
Second step: wait for the response The response and further processing are included in a function and the return of the function will be assigned to the onreadystatechange attribute of the object previously created. xhr.onreadystatechange = function() { // instructions to process the response };
Third step: make the request itself Two methods of XMLHttpRequest are used: open: command GET or POST, URL of the document, true for asynchronous. send: with POST only, the data to send to the server. The request below read a document on the server. xhr.open('GET', 'http://www.xul.fr/somefile.xml', true); xhr.send(null);
}}} xhr.onreadystatechange = function() { if(xhr.readyState == 4) { if(xhr.status == 200) document.ajax.dyn="Received:" + xhr.responseText; else document.ajax.dyn="Error code " + xhr.status; } }; xhr.open(GET, "data.txt", true); xhr.send(null); } </script> </head> <body> <FORM method="POST" name="ajax" action=""> <INPUT type="BUTTON" value="Submit" ONCLICK="submitForm()"> <INPUT type="text" name="dyn" value=""> </FORM> </body> </html>
Contd..
More efficient: The use of Ajax can reduce connections to the server, since scripts and style sheets only have to be requested once. State can be maintained throughout a Web site. JavaScript variables will persist because the main container page need not be reloaded.
A Few Drawbacks
If JavaScript is not activated, Ajax can't works. The user must be asked to set JavaScript from within options of the browser. Since data to display are loaded dynamically, they are not part of the page, and the keywords inside are not viewed by search engines.
The asynchronous mode may change the page with delays (when the processing on the server takes more time), this may be disturbing. The back button may be deactivated.
CONCLUSION
Internet-applications have many benefits over desktop applications; they can reach a larger audience, they are easier to install and support, and easier to develop. However, Internetapplications are not always as "rich" and user-friendly as traditional desktop applications. AJAX applications are browserindependent and platform-independent. With AJAX, Internet applications can be made richer and more user-friendly. AJAX is not a new programming language, but a new technique for creating better, faster, and more interactive web applications. AJAX uses asynchronous data transfer (HTTP requests) between the browser and the web server, allowing web pages to request small bits of information from the server instead of whole pages. New applications use Ajax will be very popular.
ThanQ..
Any ?????