tags:

views:

25

answers:

1

I want to call a page (click.php) on a click of a button, click.php executes a php-mysql command that inserts a value into a table. Is there a way to click the button and have the page execute without page load. An example: when you do +1 rep on this website to someones post, Im assuming its database driven and when you give them rep, it adds +1. I want to do something basically like that. Is it possible with php, if not in javascript a way to call that page?

+4  A: 

Look into XMLHttpRequest: http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=XHR
and Ajax : http://en.wikipedia.org/wiki/Ajax_(programming)

Basically: create an XMLHttpRequest,
open your .php,
send(null) and viola, you're done.

What XHR does, is it requests the page in the background and loads it in the background. Thats pretty much all you need.

If you need the content of the page, you should look into XHR.onreadystatechange and XHR.responseText

ItzWarty
oo just what i needed kthx
David
+1 for the distinction between XHR and Ajax! (People tend to think they are one and the same.)
Atli
@Atli: XHR and Ajax is like a rectangle and a square. You can have a rectangle without having a square, but you can't have a square without a rectangle.
Andrew Moore