version française

By Julien Lamarre, 2005/10/02
Other sites: The meaning of life!


AJAX without XMLHttpRequest, frame, iframe, Java or Flash

  • Only an image, a stylesheet or a .js is used for the communication between the client and the server. The communication occurs without the need for the page to reload.
  • Those techniques are not necessarily the most useful or efficient, they have been developed only for fun and to demonstrate their feasibility.
  • For the code, look at this page's source and at the associated PHP file (comments are in french though).
  • This code is free as in "credits are appreciated", so use it or modify it as you want.
  • For more informations, or to leave a comment: psssst! (in french).


with an image    with a stylesheet    with a .js
 


AJAX using a .js

  • In my opinion, this technique is the most interesting of the three (image, stylesheet, .js). The fact that the server's response is directly done in javascript is useful, the client doesn't even have to parse the response! The server can send complex structures: arrays, objects... The response can be of any length.

  • The client to server connection works by sending a request to the server using a dynamically created .js with some parameters added to its ".src" property.
    Three different ways of creating the .js are included because some of them work with some browsers while others don't. For example, Firefox does not seem to support the modification of the .src of a .js that is already loaded, but does support the creation of a new "script" element using createElement() or using innerHTML.

    The server's response is sent directly in javascript, within the generated .js!

  • The limitation I see with this technique is that you can't do POST methods, where you can with XMLHttpRequest.

    Maybe it wouldn't work with old browsers, more tests should be done. I tested it on Firefox 1.0.7, IE6 and Opera 7.

  • The associated PHP file: js.php

Your browser does not meet all the requirements for this script to work properly!
  • javascript support
  • document.getElementById() support

1. Hello World!






2. Addition

+ =




3. What's special about this number? (enter a number from 0 to 9999)

- Data taken from http://www.stetson.edu/~efriedma/numbers.html