[英]Refresh query results from included php file
I am trying to update an included PHP file and get the refreshed results and variables from that file. 我正在尝试更新一个包含的PHP文件,并从该文件中获取刷新的结果和变量。 The file
getmssg.php
is included in the foreach loop because I need in that file a row value. getmssg.php
文件包含在foreach循环中,因为我需要在该文件中添加一个行值。 The variable $ergebnis1
I get from the file getmssg.php
. 我从文件
getmssg.php
获得变量$ergebnis1
getmssg.php
。
How can I call/refresh the query values of the included PHP file without reloading the page? 如何在不重新加载页面的情况下调用/刷新包含的PHP文件的查询值?
<?php
include("chatmain.php");
?>
<?php foreach ($result2 as $key => $row): ?>
<?php include("getmssg.php"); ?>
<li data-icon="false" name="listi5" class="listitem5">
<a type="button" class="ui-btn" id=5">
<?php if ($ergebnis1 > 0) {
echo '<span class="ui-li-count">'.$ergebnis1.'</span>';
} ?>
</a>
</li>
<?php endforeach; ?>
What I have now: 我现在所拥有的:
function getmsg() {
$.ajax({
url: 'getmssg.php',
type: 'post',
success: function(output) {
//alert(output);
}
});
}
var timer;
function docount() {
timer = setInterval(function(){
getmsg();
}, 3000);
}
docount();
尝试将php forEach放入php函数中,并在ajax的成功回调中调用该函数,它将更新内容而无需页面加载
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.