Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/416.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript和JQuery问题-抓取并将YouTube数据写入页面_Javascript_Jquery_Jquery Ui_Wordpress - Fatal编程技术网

Javascript和JQuery问题-抓取并将YouTube数据写入页面

Javascript和JQuery问题-抓取并将YouTube数据写入页面,javascript,jquery,jquery-ui,wordpress,Javascript,Jquery,Jquery Ui,Wordpress,我想说我对Javascript和JQuery有一点经验,但在我的一个较新网站上工作的时间里,没有任何东西是符合我的要求的。基本上,我使用PHP将视频ID写入javascript代码,然后执行javascript代码以获取YouTube视频的标题、上传程序、视图和长度。我在Mechabyte.com上的另一个网站“最新视频”侧边栏上一切正常,但在我的新网站FirstPersonTheater.net上,一切都不起作用。我已经包含了JQuery库,但是我的脚本没有将信息写入每个帖子的div字段。我已

我想说我对Javascript和JQuery有一点经验,但在我的一个较新网站上工作的时间里,没有任何东西是符合我的要求的。基本上,我使用PHP将视频ID写入javascript代码,然后执行javascript代码以获取YouTube视频的标题、上传程序、视图和长度。我在Mechabyte.com上的另一个网站“最新视频”侧边栏上一切正常,但在我的新网站FirstPersonTheater.net上,一切都不起作用。我已经包含了JQuery库,但是我的脚本没有将信息写入每个帖子的div字段。我已经合理化了,这可能只是使用我正在构建自己的赤裸裸主题的一种效果,但我希望在构建它时解决这些问题,但由于我在头+脚本中拥有所有JQuery库的要求,我认为它仍然可以工作。这里是我的源代码,你也可以访问和检查一些元素,看看我是否遗漏了什么

基本布局假设视频ID为0000000000000:

<div class="index_post">
<a href="<?php the_permalink() ?>">
   <div class="image">
      <div class="container" style="background:url('http://img.youtube.com/vi/0000000000000/0.jpg');">
                                                                                                </div>
             <div id="data_time<?php the_ID(); ?>" style="position:absolute;z-index:9;text-decoration:none;bottom:2px;right:2px;font-size:10px;color:#fff;background:#000;padding:0px 2px;-webkit-border-radius: 4px;-moz-border-radius: 4px;border-radius: 4px;opacity:0.75;">
                    3RR:0R!
             </div>
      </div>
      <div class="postinfo">
             <div class="data_uploadedby<?php the_ID() ?>"></div>
             <div class="data_views<?php the_ID() ?>"></div>                
      </div>
      <div class="extras">
      <script type="text/javascript">
            function ytindex<?php the_ID(); echo time() ?>( data )
                    {
                    $('#data_time <?php the_ID() ?>').html( secondsToHms( data.entry[ "media$group" ][ "yt$duration" ].seconds ) );
                    $('.data_postedby<?php the_ID() ?>').html( 'by ' + data.entry[ "author" ][ 0 ].name.$t );
                    $('.data_uploadedby<?php the_ID() ?>').html( data.entry[ "title" ].$t );
                    $('.data_views<?php the_ID() ?>').html( data.entry[ "yt$statistics" ].viewCount + ' views</h3>' );
                    }
      </script>
      <script type="text/javascript" src="http://gdata.youtube.com/feeds/api/videos/0000000000000?v=2&callback=ytindex<?php the_ID(); echo time() ?>"></script>
   </div>
</a>
</div>
这里是结果CSS元素,比如缩略图显示良好,因为它们是用PHP处理的,没有其他元素加载:SoRep的链接b/c


提前谢谢!根据经验,我可以说这个网站上的大多数人都是很棒的帮手-Matt

当前版本的wordpress中已经包含jquery库。用于添加jquery库。 不要只是将脚本添加到header.php文件中

然后,为了与wordpress兼容,您还需要使用这个ready函数

jQuery(document).ready(function($){
// now you can use jQuery code here with normal $ shortcut formatting
}); 

jquery库已经包含在wordpress的当前版本中。用于添加jquery库。 不要只是将脚本添加到header.php文件中

然后,为了与wordpress兼容,您还需要使用这个ready函数

jQuery(document).ready(function($){
// now you can use jQuery code here with normal $ shortcut formatting
});