gpt4 book ai didi

javascript - 自动 mySQLi HTML 表值刷新

转载 作者:行者123 更新时间:2023-12-03 03:56:05 24 4
gpt4 key购买 nike

我希望能够刷新 HTML 表中的值(从 SQL 数据库检索),而无需重新加载页面。我希望无需按下按钮即可完成此操作。

<div id="display" class="myCustom1">
<script>
$(document).ready(function () {
// will call refreshPartial every 5 seconds
setInterval(refreshPartial, 5000)

});

// calls action refreshing the partial
function refreshPartial() {
$.ajax({
url: "data.php", //where the table is
dataType: 'script',
format: 'js'
})
}
</script>
</div>

这是我目前拥有的,但它没有显示任何内容。

最佳答案

据我所知,你没有“成功”

function refreshPartial() {
$.ajax({
url: "data.php", //where you process the data
dataType: 'script',
format: 'js',
success: function(data)
{
$("#idOfElementWhereYouWantToPutTheData").html(data);
}

})
}

“url”是您处理数据的位置,而不是获取数据的位置

关于javascript - 自动 mySQLi HTML 表值刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44938943/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com