# rcs backend to use
rcs => 'git',
# plugins to add to the default configuration
- add_plugins => [qw{goodstuff linktoimgonly lockedit mdwn_itex org sidebar}],
+ add_plugins => [qw{goodstuff linktoimgonly lockedit mdwn_itex org sidebar rawhtml}],
# plugins to disable
disable_plugins => [qw{editpage passwordauth smiley}],
# location of template files
--- /dev/null
+[[!meta title="AJAX"]]
+[[!meta date="2009-09-19 16:27:00"]]
+
+[AJAX][] is a web-buzzword that I had always thought must be more
+complicated than it really is. I finally got a chance to look into it
+and write up a simple [[example]]. The example
+
+[[!inline pagenames="example" template="raw" feeds="no"]]
+
+accesses the server-side
+
+[[!inline pagenames="data.xml" template="raw" feeds="no"]]
+
+via
+
+[[!inline pagenames="lookup.php" template="raw" feeds="no"]]
+
+[AJAX]: http://en.wikipedia.org/wiki/Ajax_(programming)
+
+[[!tag tags/programming]]
+[[!tag tags/web]]
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<dictionary>
+ <entry>
+ <word>ping</word>
+ <definition>A common dummy word for testing functionality.</definition>
+ </entry>
+ <entry>
+ <word>dummy</word>
+ <definition>One word seemed too silly...</definition>
+ </entry>
+</dictionary>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<script language="javascript" type="text/javascript">
+function getWord() {
+ return document.getElementById('word').value;
+}
+function setDef(text) {
+ document.getElementById('def').innerHTML = text;
+}
+function getHTTPObject() {
+ if (window.ActiveXObject)
+ return new ActiveXObject("Microsoft.XMLHTTP");
+ else if (window.XMLHttpRequest)
+ return new XMLHttpRequest();
+ else {
+ setDef("Your browser does not support AJAX.");
+ return NULL;
+ }
+}
+function doAJAX() {
+ httpObject = getHTTPObject();
+ if (httpObject != null) {
+ httpObject.open("GET", "lookup.php?word=" + getWord(), true);
+ httpObject.send(null); // request is on it's way...
+ setDef("Sent request for" + getWord());
+ // here's the asynchronous read:
+ httpObject.onreadystatechange = function() { respondAJAX(); }
+ }
+}
+function respondAJAX(){
+ if(httpObject.readyState == 4) {
+ setDef(httpObject.responseText);
+ }
+}
+</script>
+</head>
+<body>
+ <form action="never_call_this_invalid_page.html" method="get">
+ <p>
+ Word: <input type="text" name="word" id="word" onBlur="doAJAX();"/><br />
+ <input type="submit" value="Submit" />
+ </p>
+ <div name="def" id="def"></div>
+ </form>
+</body>
+</html>
--- /dev/null
+<?php
+// generate an xml snippet with the requested information.
+// stays server-side.
+
+$word = $_GET['word'];
+
+$ret = '';
+
+$f = simplexml_load_file('data.xml');
+foreach ($f as $entry) {
+ if ($entry->word == $word) {
+ $ret .= '<result>'.$entry->definition.'</result>';
+ // this doesn't even have to be XML, but for official "AJAX"
+ break;
+ }
+}
+if (strlen($ret) == 0) {
+ $ret .= '<result>'.$word.' not found</result>';
+}
+echo '<?xml version="1.0" encoding="UTF-8" ?>';
+echo $ret;
+
+?>