在wordpress post中使用ajax提取HTML内容


Pulling HTML content using ajax in wordpress post

好的,我目前正在一个网站上工作,我想在每个帖子中嵌入一个时间轴。我正在使用WordPress。我插入的时间轴会因帖子而异,所以这个时间轴不能插入到我使用的实际主题中?我也是PHP、HTML和JS的新手。但我已经搜索了大量的论坛,不能为我的生活弄清楚如何做到这一点。不管怎样,这是我时间表的链接。http://derikgrass.com/timeline/xml/2012-2014/pbj/index.html

这里是一个链接到时间轴嵌入在我的网站使用iFrame。http://www.derikgrass.com/events/?p=526

iFrame将工作得很好,只有iFrame需要比时间轴本身大得多,因为当你点击时间轴上的事件时,时间轴就会扩展,正如你可以从我提供的链接中看到的那样。以下是时间轴html代码:

<meta charset="utf-8">

<title>TimelineXML</title>
<meta name="description" content="">

<link rel="stylesheet" href="css/timelinexml.sleek.css">

    <section class="demo">
        <p> <br/><br/> </p>
        <div class="demo-box">
        <div id="my-timeline">
            <div class="timeline-html-wrap" style="display: none">

            </div>
            </div>
        </div>
    </section>
</div>

<!-- JavaScript at the bottom for fast page loading -->
<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><'/script>')</script>

<!-- scripts concatenated and minified via build script -->
<script defer src="js/mylibs/timelinexml.js"></script>
<script defer src="js/script.js"></script>
<!-- end scripts -->

我想将此直接嵌入到我创建的特定帖子中。如果有人能够帮助我写代码,以嵌入这个时间表,我会非常感激。谢谢。

我想你的意思是你要把他放在你的html

<iframe src="http://derikgrass.com/timeline/xml/2012-2014/pbj/index.html" scrolling="no" height="400" width="900"> </iframe>

并更改宽度

但是你应该去源代码(所以跟随那个链接),你会看到他使用了一个很好的js文件使它工作。如果你这样做,你会看到他正在使用这个脚本:

http://codecanyon.net/item/jquery-timelinexml/1448100

我不喜欢从那里看到的脚本,我相信他们是时髦的网站,但是嘿,这是你的电脑和服务器。你决定。