Javascript 从PHP文件结果自动刷新标题网页

Javascript 从PHP文件结果自动刷新标题网页,javascript,php,refresh,title,titlebar,Javascript,Php,Refresh,Title,Titlebar,我有一个php文件,可以从数据库中生成一个值,我希望该值在网站的标题框中不断显示 我试过: <script> function autoRefresh_title() { $.post("currentbank.php").done(function(response){ document.title(response) setInterval('autoRefresh_title()', 1000); </scri

我有一个php文件,可以从数据库中生成一个值,我希望该值在网站的标题框中不断显示

我试过:

   <script>
 function autoRefresh_title()
 {
     $.post("currentbank.php").done(function(response){
     document.title(response)

  setInterval('autoRefresh_title()', 1000); 
            </script>

函数autoRefresh_title()
{
$.post(“currentbank.php”).done(函数(响应){
文件.标题(答复)
setInterval('autoRefresh_title()',1000);
上面的代码位于index.php文件中,currentbank.php为:

<?php
@include_once ("set.php");
$game = fetchinfo("value","info","name","current_game");
echo round(fetchinfo("cost","games","id",$game),2);
?>

PS:set.php只是登录信息

document.title(response);
改为:

document.title = response;

请确保问题是完整的(您在提供的代码中缺少了很多右括号)。当代码失败时,您还应该提供一个简短的信息(假设它不适合您,因为您在这里提问)。您只编辑了部分问题,javascript代码可能仍然不完整(或不正确,如@Akshay所述)。document.title不是一个函数。我认为您的脚本不起作用,因为它包含错误。请尝试以下操作:
function autoRefresh_title(){$.post(“currentbank.php”,function(response){document.title=response;},'text');}setInterval(autoRefresh_title,1000);
你检查过浏览器控制台吗?我想你有JS错误。你能给出你页面的链接吗?