使用ajax和php刷新b内容

时间:2019-07-09 10:40:32

标签: php ajax

<script type="text/javascript">
    function dis() {
        if (window.XMLHttpRequest) {
            // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        } else {
            // code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
                document.getElementById("bell").innerHTML = this.responseText;
            }
        };
        xmlhttp.open("GET", "test.php", false);
        xmlhttp.send();
    }
    
    dis();
    setInterval(function() {
            dis();
    }, 5000) 

</script>
<a id="coll" class="collapsed" data-toggle="collapse" href="#togglePages">
	<i class="menu-icon icon-cog"></i>
	<i class="icon-chevron-down pull-right"></i><i class="icon-chevron-up pull-right"></i>
	Order Management
	<b class="label orange pull-right"></b>
</a>

<?php
include('config.php');
$status = 'Delivered';                                   
$ret1 = mysqli_query($con,"SELECT * FROM Orders where orderStatus!='$status' || orderStatus is null ");
$num1 = mysqli_num_rows($ret1);
echo $num1;
?>

我需要刷新计数器才能尝试数据库中表中发生的每一次更新,但是对我来说不起作用

此代码有什么问题?

0 个答案:

没有答案