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?

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

2 Comments

+1 for the distinction between XHR and Ajax! (People tend to think they are one and the same.)
@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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.