将滚动条附加到jQuery中的元素

Ton*_*Dev 5 javascript php jquery

我有一个带有"Whats Playing"信息栏的修改过的jPlayer.

信息栏显示来自PHP文件的回显信息.

我需要将一个卷轴附加到该播放器栏上的信息,但我似乎无法确定它.

滚动条位于单独的js文件中.

http://www.maxvergelli.com/jquery-scroller/

jQuery的:

getCurrentTrack();

$('.now_playing').SetScroller({
    velocity: 50,
    direction: 'horizontal',
    startfrom: 'right',
    loop: 'infinite',
    movetype: 'linear',
    onmouseover: 'pause',
    onmouseout: 'play',
    onstartup: 'play',
    cursor: 'pointer'
});

function getCurrentTrack() {
    $('.now_playing').load('/player/readerPlayer2.php');
    setInterval(function() {
        $('.now_playing').load('/player/readerPlayer2.php');
    }, 9000);
};?
Run Code Online (Sandbox Code Playgroud)

PHP信息:

<?php
header("Expires: Tue, 03 Jul 2040 06:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

$xml = simplexml_load_file("http://**.**.**.**:8000/live.xspf"); 

foreach ($xml->trackList->track as $data) { 
    $radio = $data->location;
    $song  = $data->title;  
    $info = $data->listeners;   
}
echo '<div class="IceSong">'.$song.'</div>';
?>
Run Code Online (Sandbox Code Playgroud)

sup*_*her 1

您是否尝试过在浏览器控制台中查找输出?

我刚刚尝试过这个,当我从加载 uri 中删除第一个斜杠时,它似乎对我来说工作得很好。

请注意,您可以简单地从 setInterval 再次调用 getCurrentTrack 函数,而不是重新声明它。

    function getCurrentTrack() {
        $('.now_playing').load('player/readerPlayer2.php');
        setInterval(getCurrentTrack, 9000);
    }
Run Code Online (Sandbox Code Playgroud)

另一件需要指出的事情是,在函数声明后不需要使用分号。有关更多信息,请参阅为什么我应该在 javascript 中的每个函数后面使用分号?

希望这对您有所帮助,-让我知道您的进展如何。