Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

The Ajax transport method

There's more to Ajax than XMLHttp

Mr. Jack D Herrington (jherr@pobox.com), Senior Software Engineer, Leverage Software, Inc.
A senior software engineer with more than 20 years of experience, Jack Herrington is the author of three books: Code Generation in Action, Podcasting Hacks, and PHP Hacks. He is also the author of more than 30 articles. You can contact him at jherr@pobox.com.

Summary:  Discover three Ajax data transport mechanisms (XMLHttp, script tags, and frames or iframes) and their relative strengths and weaknesses. This tutorial provides code for both the server side and the client side and explains it in detail to provide the techniques you need to put efficient Ajax controls anywhere you need them.

Date:  06 Jun 2006
Level:  Intermediate PDF:  A4 and Letter (157 KB | 29 pages)Get Adobe® Reader®

Activity:  14745 views
Comments:  

Before you start

Learn what to expect from this tutorial and how to get the most out of it.

About this tutorial

With all the hype around Asynchronous JavaScript and XML (Ajax), you would think that more people would know how it works. But all engineers seem to talk about is the XMLHttp method of getting data to and from the server. If this method is all you know, then what you can do with Ajax is limited. In reality, there are three ways to get data to and from the server: the XMLHttp method, the <script> tag method, and the frame or iframe approach. Unless you know all three of these methods (and their relative strengths and weaknesses), you won't get the full picture. This tutorial shows you all you need to know about the critical transport piece of the Ajax puzzle that fits between the client and the server.

In addition to understanding how the client requests data from the server, there's the question of what type of data is going across the wire. Most Ajax articles talk about Extensible Markup Language (XML), but you can actually move plain text, Hypertext Markup Language (HTML) pages, or JavaScript code. You have a lot of reasons for thinking outside the XML box.

In this tutorial, you will:

  • Create the database back end for the example.
  • Build a set of server-side pages that provide access to the database data.
  • Build a set of pages based on XMLHttp that use the data services.
  • Build a set of pages based on iframes that use the data services.
  • Build a set of pages based on <script> tags that use the data services.

Objectives

In this tutorial, you will learn the three primary methods of Ajax transport and their use in practice with PHP and JavaScript code.


Prerequisites

This tutorial assumes a basic knowledge of XML, HTML, and the JavaScript and PHP programming languages. To run the examples in this tutorial, you need:

  • A PHP server that has access to a server running MySQL.
  • A Web browser. (I recommend either Mozilla Firefox or Microsoft® Internet Explorer V6.)

System requirements

To run the examples in this tutorial, you will need to install the Apache Web server as well as PHP. You will also need access to a Web browser, such as Mozilla Firefox.

1 of 9 | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=XML, Java technology, Open source, Web development
ArticleID=126179
TutorialTitle=The Ajax transport method
publish-date=06062006
author1-email=jherr@pobox.com
author1-email-cc=dwxed@us.ibm.com