簡體   English   中英

Ajax刷新了php但沒有更新

[英]Ajax is refreshed php but not updated

信息不會更新,或者更確切地說是刷新,但不會取出新信息。 如果我輸入data.php,那么如果它取出新信息,就好像它保留了緩存,並沒有添加新信息。 進入data.php后,ajax中也出現了一切。

數據.php:

    <?php 
$conn = new mysqli('localhost', 'xxx', 'x', 'xx');
if ($conn->connect_error) {
    die("Connection error: " . $conn->connect_error);
}
$result = $conn->query("SELECT * FROM `users`");
if ($result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {


        echo  
 " <tr>
    <td>".$row['username']."</td>
    <td>Jackson</td>
    <td>94</td>
  </tr>";
    }
}
?>

阿賈克斯:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
    ajax_call = function() {
        $.ajax({ //create an ajax request to load_page.php
            type: "GET",
            url: "data.php",
            dataType: "html", //expect html to be returned                
            success: function (response) {

                $("#responsecontainer").html(response);

            }
        });
    };
    var interval = 1000;
    setInterval(ajax_call, interval);
});
</script>

編輯:只有當您手動輸入data.php然后在ajax頁面中自動更改它時,您才更改ajax中的數據。

僅從 POST 更改 GEt 並且工作正常。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM