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 developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

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:  10595 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



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

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

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Special offers