【发布时间】:2025-11-21 17:35:02
【问题描述】:
我正在使用 jQuery“加载”函数从外部 PHP 文件中获取产品名称及其描述。此外,我希望使用 fadeIn() 函数在页面上显示此文本。如何在我的 jQuery 代码中做到这一点?
$('document').ready(function() {
refreshEPosts();
function refreshEPosts(){
$('#crPanel').load('getNewPosts.php', function(){
setTimeout(refreshEPosts, 1500);
});
}
});
更新
$('document').ready(function() {
refreshEPosts();
function refreshEPosts(){
$('#crPanel').load('getNewPosts.php', function(data) {
//For now, lets just log the data
console.log(data); //should be your echo'd php stuff
setTimeout(refreshEPosts, 1500);
$('#crPanel').fadeIn(data);
});
}
});
【问题讨论】:
-
从 php 文件返回的内容...现在您只需每 1.5 秒调用一次
.load函数。 -
它正在使用 mysql 从数据库中返回名称和一些文本——我只是在页面中回显它
-
收到下一批数据时会发生什么?
#crPanel是否应该在使用新数据更新之前淡出?
标签: php jquery jquery-load