如何使用jQuery更新在PHP中创建的网页中的文本 [英] How to update text in a webpage created in PHP using jQuery

查看:73
本文介绍了如何使用jQuery更新在PHP中创建的网页中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道您可以使用jQuery脚本更新,替换或删除网页的各个部分,但我在我的主页面上的一台服务器上有一个在线人数的计数器。



我想知道是否可以使用jQuery每隔X秒更新一次这个数字以及怎么做?



代码我我现在用来获取页面中的玩家数量是这样的:



I know you can update, replace or remove parts of a webpage using jQuery scripts, but I got a counter of the number of people online on one of my servers in my main wepage.

What I wanted to know if it's possible to make this number update every X seconds using jQuery and how to do it?

The code I am using right now to get the player count in the page is this:

<?php
	include "Status.php";
	$server = new Status("127.0.0.1", 11115);
	echo "(";
	echo $server->online_players;
	echo "/";
	echo $server->max_players;
	echo ")";
?>





不是Status.php它只是一个PHP脚本,它获取运行在该服务器上的服务器的状态港口。



任何人都知道我怎么做才能更新?



请注意在更新时必须运行PHP代码以获得当前数量的玩家。



谢谢。



PD:我是js和jquery的新手,对不起,如果这是基本的或简单的。



Not that Status.php it's just a php script that gets the state of a server running at that port.

Anyone know how could I make so it gets updated?

Note that to get the amount the php code must be run at the moment of updating to get the current amount of players.

Thanks.

PD: I am new to js and jquery, sorry if this is basic or easy.

推荐答案

server = new Status(127.0.0.1, 11115);
echo(;
echo
server = new Status("127.0.0.1", 11115); echo "("; echo


server-> online_players;
echo/;
echo
server->online_players; echo "/"; echo


server-> max_players;
echo);
?>
server->max_players; echo ")"; ?>





不是Status.php它只是一个PHP脚本,它获取运行在该服务器上的服务器的状态港口。



任何人都知道我怎么做才能更新?



请注意在更新时必须运行PHP代码以获得当前数量的玩家。



谢谢。



PD:我是js和jquery的新手,对不起,如果这是基本的或简单的话。



Not that Status.php it's just a php script that gets the state of a server running at that port.

Anyone know how could I make so it gets updated?

Note that to get the amount the php code must be run at the moment of updating to get the current amount of players.

Thanks.

PD: I am new to js and jquery, sorry if this is basic or easy.


这篇关于如何使用jQuery更新在PHP中创建的网页中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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