Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在不重新加载页面的情况下刷新div和mysql代码_Php_Jquery_Mysql_Css - Fatal编程技术网

Php 如何在不重新加载页面的情况下刷新div和mysql代码

Php 如何在不重新加载页面的情况下刷新div和mysql代码,php,jquery,mysql,css,Php,Jquery,Mysql,Css,嘿,我对这个有点陌生,但我目前正在编写一个小游戏,我有一个使用jquery、css和php的健康栏。我使用mysql查询从数据库中获取健康值,它可以工作,但只有在我重新加载页面时才能工作。我希望健康栏的值每x秒更新一次 函数UpdateStats(){ $.getJSON('demo1.php',函数(stats){ $('#pbar_innerdiv')。设置动画({ 宽度:(stats.health)+'%' }, 200); }); }, 1000; < /脚本> \pbar\u ou

嘿,我对这个有点陌生,但我目前正在编写一个小游戏,我有一个使用jquery、css和php的健康栏。我使用mysql查询从数据库中获取健康值,它可以工作,但只有在我重新加载页面时才能工作。我希望健康栏的值每x秒更新一次


这个比setinterval更好,当第一个迭代完成时,它将调用第二个迭代。希望能有所帮助


解释:
首先在完成UpdateStats()之后调用UpdateStats()函数,然后等待3秒钟,然后调用第二次迭代。这一步将重复执行

这就是php的外观,setTimeout JS函数在哪里?“1000;”在这里没有意义。