Cool Penguin

PlainAjax - keeping Ajax simple

Tutorial

Post data from HTML input elements

Task description

Submitting data from HTML input fields to the server. The server echoes the received posted data.

Working example

HTML inputs
Text input:
Checkbox: Check
Radio button:
Option 1
Option 2

Textarea:

Click here to post HTML inputs to the server

Server response

The server's response will appear here

Implementation steps



The HTML Code

<div id="myhtmlinputs">
  <input type="text" name="textinput" value="Some input text data" size="50" />
  <input type="checkbox" name="checkboxinput" value="Checkbox is checked" />
  <input type="radio" name="radioinput" value="radiooption1">
  <input type="radio" name="radioinput" value="radiooption2">
  <textarea name="textareainput"></textarea>
</div>
<a onclick="plainajax.request('respurl: dumppost.php; resultloc: myresult; paramloc: myhtmlinputs')">Click here to post HTML inputs to the server</a><br />
<div id="myresult"></div>

Note: the server-side scripts (defined in respurl attribute) can be implemented in any language, java, ruby, php, etc..

Check another example on how to