Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: Book excerpt: Jump into AJAX development

In this article, you'll build a simple AJAX (Asynchronous JavaScript and XML) application.

Tutorial Details:

This exercise is for the most impatient readers willing to start coding ASAP, but it assumes you're already familiar with JavaScript, PHP, and XML.

You'll create here a simple AJAX Web application called quickstart, where the user is requested to write his or her name, and the server keeps sending back responses while the user is writing. Figure 1 shows the initial page, index.html, loaded by the user.

While the user is typing, the server is being called asynchronously, at regular intervals, to see if it recognizes the current name. The server is called automatically, approximately one time per second, which explains why we don't need a button (such as a Send button) to notify when we're done typing. (This method may not be appropriate for real login mechanisms, but it's very good to demonstrate some AJAX functionality.)

Maybe at first sight, there's nothing extraordinary going on there. We've kept this first example simple on purpose, to make things easier to understand. What's special about this application is that the displayed message comes automatically from the server, without interrupting the user's actions. (The messages are displayed as the user types a name). The page doesn't get reloaded to display the new data, even though a server call needs to be made to get that data. This wasn't a simple task to accomplish using non-AJAX Web development techniques.

The application consists of the following three files:
1. index.html is the initial HTML file the user requests.
2. quickstart.js is a file containing JavaScript code that is loaded on the client along with index.html. This file will handle making the asynchronous requests to the server, when server-side functionality is needed.
3. quickstart.php is a PHP script residing on the server that gets called by the JavaScript code in the quickstart.js file from the client.


 

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
Book excerpt: Jump into AJAX development

View Tutorial:
Book excerpt: Jump into AJAX development

Related Tutorials:

Java in a Nutshell Code Example
The Java programming examples shown here are from the book Java in a Nutshell , by David Flanagan, published by O\'Reilly & Associates.
 
Java 2 introduces print capability to the Swing Forum - JavaWorld June 1999
Java 2 introduces print capability to the Swing Forum - JavaWorld June 1999
 
JavaWorld December 1999
JavaWorld December 1999
 
Code generation using Javadoc - JavaWorld August 2000
Code generation using Javadoc - JavaWorld August 2000
 
Which JSP book serves up the best lesson?
Which JSP bookAs for Web servers/databases, just mentioning a server in the book is not sufficient to be listed here.
 
Printing in Java, Part 4 - JavaWorld February 2001
Printing in Java, Part 4 - JavaWorld February 2001
 
Performance books put to the test - JavaWorld March 2001
Performance books put to the test - JavaWorld March 2001
 
Finalists announced for JavaWorld Editors' Choice Awards
Finalists announced for JavaWorld Editors' Choice Awards
 
Design patterns make for better J2EE apps
Design patterns make for better J2EE apps
 
Java tools reign supreme - JavaWorld celebrates the leading Java tools
Java tools reign supreme - JavaWorld celebrates the leading Java tools
 
Good article on how to adopt XP
Good article on how to adopt XP xtreme programming (XP) is a software development methodology that makes coding the primary activity. By promoting values such as simplicity and feedback, XP allows Java programmers to incrementally develop and test applic
 
Java Testing and Design
Java Testing and Java Test and Design is the companion to any book on Java software development practices, techniques, and testing. Software developers, QA analysts and IT managers working in large corporate IT groups, software development companies, and
 
Excerpt from Apache Axis Live
Excerpt from Apache Axis Live This chapter, "Getting Started with the Apache Axis Project," you will take "a brief look at what Axis is and how it implements some of the SOAP services.
 
Improving JSF by Dumping JSP
Improving JSF by Dumping JSP After a long wait and high expectations, JavaServer Faces (JSF) 1.0 was finally released on March 11, 2004. JSF introduces an event-driven component model for web application development, similar in spirit and function to t
 
Creating Varargs in Java 1.5 Tiger
Creating Varargs in Java 1.5 Tiger In this excerpt from Chapter 5 of the book, Brett and David cover how to create and iterate over variable-length argument lists (better known as varargs), which will have you writing better, cleaner, more flexible code
 
Core Java Data Objects Excerpt
This book excerpt is from Core Java Data Objects,
 
Tutorial for Developing your first JSPs tags
We have seen how servlets and JSPs can be used to build a web application. These technologies go some distance toward making web development easier, but do not yet facilitate the separation of Java from HTML in a reusable way. Custom tags make this possib
 
Programming Jakarta Struts: Using Tiles, Part 2
In part two in this series of book excerpts on using tiles from Programming Jakarta Struts, learn how to install and configure tiles, as well as get an overview on tiles.
 
The SATSA Developer's Guide
Describes how to use the SATSA APIs in MIDP applications. It includes lucid explanations and example code that illustrate how to communicate with a smart card and how to use cryptographic services. It is based on the SATSA Reference Implementation 1.0.
 
Introduction to the Solaris Development Environment
Take advantage of the numerous interfaces, frameworks, and tools for the Solaris OS. This new book provides an overview of the Solaris OS with abstracts of key manuals for Solaris developers and links to sources of detailed information.
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.