php执行页面 [英] php execute page

查看:77
本文介绍了php执行页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要单击按钮就调用页面(click.php),click.php执行一个php-mysql命令,该命令将一个值插入表中。有没有一种方法可以单击按钮并使页面执行而无需页面加载。例如:当您在此网站上对某人的帖子执行+1 rep时,Im假设其数据库是由数据库驱动的,当您为他们提供rep时,它将添加+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?

推荐答案

请查看XMLHttpRequest: http://www.google.com/search?sourceid=chrome& ie = UTF-8& q = XHR

和Ajax: http://en.wikipedia.org/wiki/Ajax_(编程)

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

基本上:
创建一个XMLHttpRequest,

打开您的.php,

send(null)和中提琴,您完成了。

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

XHR的作用是,它在后台请求页面并将其加载到后台。那几乎就是您所需要的。

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

如果需要页面的内容,则应查看XHR.onreadystatechange和XHR.responseText

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

这篇关于php执行页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆