Example - Chatbox

This example shows how easily and quickly you can implement a chatbox using DynAjax engine.

A sample code

---Place to display Results---

<div id="result"></div>

---Form to enter a message to send---

<div id="params">
  <input type="button" value="Send"
    onclick="dynajax.request('respfile: messageboard.php; resultloc: result;
    paramloc: params;')" />
  <input name="mymessage" type="text" value="" size="60" />
</div>

---For autorefresh--

<script type="text/javascript">
  dynajax.request('respfile: messageboard.php; resultloc: result; refreshtime: 3000;');
</script>

The chatbox in action

Notes:

  • The messageboard.php responsefile inserts the posted "mymessage" data to a database table, then writes the last 10 messages to the output. The result will be placed into the "result" div once it is acquired.
  • The "For autorefresh" code makes sure the messagebox is refreshed in each 3 seconds. See reference to learn more about this feature.
Text content editor