Tuesday, 6 November 2007

php alternative to using ajax

PATAJAX - php alternative to AJAX

I found an excellent alternative to ajax which uses php.

requirements:
client - javascript, modern brower
server - php

I've modified (simplified) and extended the original from ideas at:

http://www.phpit.net/article/ajax-php-without-xmlhttprequest/
http://www.shawngo.com/gafyd/index.html
http://www.shawngo.com/rating-script.php

and others to come up with an ajax alternative which returns a response via php to a div.

How to make it work:

1. add script tag to an html document (src=patajax.php)
2. in your html, create a div tag with an id - the response from the server will arrive here
3. your html needs to trigger the patajax javascript function, specifying the php (e.g. patjax.php) to call with the id of the div tag specified above and any additional parameters
4. the patajax.php will return the html to the div tag specified in 3

download
here's the zip file with the
patajax.html and the patajax.php


try it here

screenshots

i.e


firefox

konqueror (plasmanetix linux)


nokia n70 phone (opera)