There is not much more to it than that, but do read this afterwards:
http://www-128.ibm.com/developerworks/views/web/libraryview.jsp?search_by=Mastering+Ajax
It is a series of articles, so far 3 of them (there were two when someone
posted it) but it goes step by step and has good code.
To mention a couple of things I learned there that I could pick in this
example:
1) With old Internet Explorers, the ActiveX object has another name, so
there are three ways to call it, older IE, newer IE and all the rest.
2) Besides checking the readyState property on the callback function, you
better check the status that the server sends. The readyState might be 4,
meaning it received a complete response from the server, but that response
could be an infamous "404 page not found" message or a "500 server error".
There are lots of older IEs (and we would still be leaving out a few
surviving ones, of all makes, even older than this), and errors such as a
404 have to be dealt with, they can happen and they are completely out of
our control.
An idea I got from another article describing how Google does it on its maps
site is that what you send can be javascript code so that the responseText
you pass it to an Global.eval() method. With some one-letter functions
defined in an included <script src="wherever">, the response might contain
calls to these functions and parameters, such as
"d('arg1',2,'arg3');d('arg4',5,'arg6');" or plain code: "alert('you got
it');". I believe that gets as concise and flexible as it gets.
Satyam
----- Original Message -----
From: "Karuna" <karuna.kgx@xxxxxxxxx>
To: <php-general@xxxxxxxxxxxxx>
Sent: Wednesday, February 15, 2006 11:13 PM
Subject: Re: php & ajax
There's a nice, simple intro to ajax here:
http://marc.theaimsgroup.com/?l=php-general&m=112198633625636&w=2
"pete" <petekin74@xxxxxxxxxxx> wrote in message
news:43F391D3.1000408@xxxxxxxxxxxxxx
ello all, Im a beginner at php. but I was able to get this script to
work.
Now I am looking to have it automatically refresh itself using ajax every
10 seconds.
Can somebody explain or show me how to do this.
Thank you.
PHP Code:
| | |<?php
$httpfile =
file_get_contents('http://www.game-monitor.com/client/buddyList.php?uid=8654&listid=0&xml=1');
$doc = DOMDocument::loadXML($httpfile);
$myBuddyNodes = $doc->getElementsByTagName('buddy');
/////not neccessary, but im using it
$nameStatusDoc = new DOMDocument('1.0', 'iso-8859-1');
$rootElement = $nameStatusDoc->createElement('PetesList');
$rootElement = $nameStatusDoc->appendChild($rootElement);
/////////
echo "<table border = '0' cellpadding= '2'
bgcolor='#616042'>\n<thead><tr><th></th><th></th><tr></thead>\n";
foreach ($myBuddyNodes as $node)
{
echo "<tr>";
echo "<td><font
size='-1'>".$node->firstChild->nextSibling->nodeValue."</font></td>";
if($node->firstChild->nextSibling->nextSibling->nextSibling->nodeValue
== "Online") |
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php