[FAQ] How can I process a link/form without allowing the page to refresh or reload?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

[FAQ] How can I process a link/form without allowing the page to refresh or reload?

From: R. Rajesh Jeba Anbiah <ng4rrjanbiah@rediffmail.com>
Date: Sun Jul 03 2005 - 18:50:34 CEST

Q: How can I process a link/form without allowing the page to refresh
or reload?
A:
1. Using PHP alone:
   Send a HTTP header status with 204
2. IFRAME hack:
   POST or link the request to the invisible IFRAME. Need to name the
IFRAME and use it for "target"ing.
3. JavaScript:
   Use XMLHttpRequest object and preferably with AJAX technique.

Caveats:
(1) breaks usability (especially without JavaScript alert) as it is de
facto to expect results after clicking the link or submitting the form.
Also, HTTP Status 204 is not supported in few older browsers.
(2) is kind of dirty hack that breaks browser's back button
(3) totally breaks accessibility criteria

Refer:
http://www.sitepoint.com/print/no-refresh-links
http://ppewww.ph.gla.ac.uk/~flavell/www/status204/
http://www.faqs.org/rfcs/rfc2616.html
http://www.php.net/header
http://jibbering.com/2002/4/httprequest.html
http://en.wikipedia.org/wiki/AJAX

++++
@revision 1 Initial
@revision 2 Reworded for clarity. More links
@todo Better question. Someone may help.
Received on Mon Oct 17 21:01:32 2005