Tutorial: Simple form-submit using AJAXSeite 1 von 3
Everybody is talking about AJAX, so I do.
What is AJAX?
It stands for Asynchronous JavaScript and XML. The goal is, as you know, if you do any HTTP_POST on a website, the site will be reloaded. Sometimes, this is not so usefull. If you have a big site with many images and only need to send a little form to the server, AJAX can be a good idea, because a full reload is not.
What is new on AJAX?
Nothing! AJAX is a technique used with Javascript, no programming-language. You do not need any server- or clientside installations, no frameworks or anything else. If you just want to send simple requests and interpret the answer you will not need more than 20 lines of javascript-code.
What should I have in mind?
Some people have Javascript disabled. Find your own way, but I would always take care of that. If you want, it is possible to offer some alternative way, for those without Javascript. Of course, with a page-reload, but the site still work on this way. For more, take a look at the tutorial.
author: Stephan Spies info(at)optima-software(dot)de
date: 2006/08/01
version 1.0.
A. Description
This is a very simple tutorial to understand Ajax-Requests and how it can work with PHP. What we try to do is:
- Create a HTML-Form with some $_POST values, that can be sent to a php-file by a normal submit or, if Javascript is enabled, by an AJAX request. The result, of course, must be the same in both ways.
- We would like to use the same PHP-function to answer the request, so there will be no redundant code.
- At least, we will try to write down some JavaScript-functions that can be used in more than one form.









Antwort schreiben