Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/391.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
Javascript 如何每隔5秒检索内容更改p标记的值?_Javascript_Jquery_Html - Fatal编程技术网

Javascript 如何每隔5秒检索内容更改p标记的值?

Javascript 如何每隔5秒检索内容更改p标记的值?,javascript,jquery,html,Javascript,Jquery,Html,如何每隔5秒检索内容更改p标记的内容? 我的代码片段如下 var字; setInterval(函数(){ $.get(”http://localhost/chrome-notification/dosya.php,函数(数据){ 回调(数据); }); },3000); 函数回调(数据){ 字=数据; $('container').html(word); } deneme 您的第二个脚本标记超出了正文,请尝试将其放在之前,并进行更改 $('container').html(word);

如何每隔5秒检索内容更改p标记的内容? 我的代码片段如下

var字;
setInterval(函数(){
$.get(”http://localhost/chrome-notification/dosya.php,函数(数据){
回调(数据);
});
},3000);
函数回调(数据){
字=数据;
$('container').html(word);
}

deneme


您的第二个
脚本标记
超出了正文,请尝试将其放在
之前,并进行更改

$('container').html(word); 


希望它能起作用:)

你在这里想说什么(为了不改变p标记的值)??你的第二个脚本标记超出了正文,请尝试将其放在前面,然后重新运行代码not working maaan,仍然返回“deneme”。p标记的值未更改。看起来您的“url”或php文件有问题。因为我已经在我的pc和JSFIDLE上试过你的代码,所以它工作得很好。你能提供你要加载的文件吗!?谢谢vivek。我解决了这个问题。问题是,文本变量未定义。因为“message:text”节程序在ajax请求之前运行
$('#container').html(word);