php execute page

时光怂恿深爱的人放手 提交于 2020-01-05 04:34:11

问题


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:


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



来源:https://stackoverflow.com/questions/2331718/php-execute-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!