This is a
legacy page.

HttpTerminal

HttpTerminal is a simplified wrapper for XMLHttpRequest. It's a component of Argo, but I decided it was useful enough to be its own separate package.

On this page:

Features

  • It hides the mechanics of using the XMLHttpRequest object, such as defining ready state change handlers.
  • It sends and receives plain text only. No XML.
  • You can re-use an HttpTerminal instance indefinitely.

Usage

This is only minimally documented, but it's pretty simple, and there is an example provided with the source code. I may write better docs later, but don't hold your breath.

Client

First, create a new HttpTerminal instance. The constructor takes one optional argument. If a URI is passed as that argument, the instance will post to that URI. Otherwise, it will post to the URI of the current document.

Use the object through its send() method, which takes three arguments:

text
The string to post to the server.
responseListener
A function that receives a single argument: the string returned from the server.
failureListener
A function that receives a single argument: an object representing a failure related to the HTTP request.

Server

The client posts the string to the server as raw post data, without modification. How the server handles that is up to you.

HttpTerminal offers a structured way of doing so, written in PHP 5, which you can use if you want. An example is included in the download.

Download

Argo is distributed under the terms of the GNU General Public License. A copy of the license is included in the download.

Advertisements