自动刷新Wordpress发布区 [英] Auto Refresh Wordpress Post Div

查看:63
本文介绍了自动刷新Wordpress发布区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在每次更新具有蓝色ID的div时自动刷新该ID. 我知道Jquery代码看起来像这样:

I would like to autorefresh a certain div with the ID of blue everytime I update a post with that ID. I know the Jquery code looks something like this:

var auto_refresh = setInterval(
function ()
{
$('#blue').load('load.php').fadeIn("slow");
}, 10000);

我不想加载"load.php",而是希望重新加载div中的更新内容,这是通过wordpress管理面板从外部完成的.任何帮助将不胜感激.谢谢大家!

Instead of loading "load.php" I would just like to reload the updated contents in the div which is done externally through the wordpress admin panel. Any help would be greatly appreciated. Thanks everyone!

推荐答案

这也是我的问题,一个主意:

This was my Problem too, an idea:

您可以创建一个JavaScript函数来加载由WordPress创建的RSS文件的内容( http://domain.tld/feed/rss/),然后使用.html()

You can create a JavaScript function which loads the content of your RSS file created by WordPress (http://domain.tld/feed/rss/) and puts the content of the new article with the id xyz in the div blue using .html()

function getContent(id) {
    // Here the Function which loads your RSS File and Match your Content of your Article with the_ID = id
}

var content = getContent(<?php the_ID(); ?>); // the_ID() is a WordPress function

function refresh(content) {
    $.get(content, function getNew(rssfile) {
        $("#blue").html('');
        $("#blue").html(rssfile);
    });
};

$(function(){
    refresh(content);
    var int = setInterval("refresh(content)", 10000);
});

我现在将搜索另一个想法,但是这个示例只是一个想法,因为我没有找到其他任何方法来刷新ID = id;的div;

I will search now for an other Idea, but this example is just an idea, because i haven't find anything else how to refresh just an div with id = id;

这篇关于自动刷新Wordpress发布区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆