From 8df9488ddb67444186719f0d38dce1384e21be63 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 13 Oct 2010 21:42:14 -0400 Subject: [PATCH] Upgrade AJAX example to work with content served as application/xhtml+xml. --- posts/AJAX/example.html | 29 +++++++++++++++++++---------- posts/AJAX/lookup.php | 6 ++++-- 2 files changed, 23 insertions(+), 12 deletions(-) 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; ?> -- 2.26.2