From: W. Trevor King Date: Thu, 14 Oct 2010 01:42:14 +0000 (-0400) Subject: Upgrade AJAX example to work with content served as application/xhtml+xml. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8df9488ddb67444186719f0d38dce1384e21be63;p=blog.git Upgrade AJAX example to work with content served as application/xhtml+xml. --- diff --git a/posts/AJAX/example.html b/posts/AJAX/example.html index d69980b..3dab331 100644 --- a/posts/AJAX/example.html +++ b/posts/AJAX/example.html @@ -3,12 +3,20 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - @@ -40,10 +49,10 @@ function respondAJAX(){

- Word:
- + Word:
+ Click somewhere else to lookup word.

-
+

diff --git a/posts/AJAX/lookup.php b/posts/AJAX/lookup.php index e8c0472..9f6e13d 100644 --- a/posts/AJAX/lookup.php +++ b/posts/AJAX/lookup.php @@ -10,14 +10,16 @@ $f = simplexml_load_file('data.xml'); foreach ($f as $entry) { if ($entry->word == $word) { $ret .= ''.$entry->definition.''; - // this doesn't even have to be XML, but for official "AJAX" + // this doesn't even have to be XML, but we're doing official "AJAX" break; } } if (strlen($ret) == 0) { $ret .= ''.$word.' not found'; } -echo ''; + +header("Content-Type: text/xml; charset=UTF-8"); +echo '<'.'?xml version="1.0" encoding="UTF-8" ?'.">\n"; echo $ret; ?>