Jquery插件:Jplayer动态播放列表

时间:2016-01-29 16:28:26

标签: jplayer

请有人帮助我...我正在使用jplayer插件在我的网站上播放音乐。

的javascript:

var cssSelector = {
            jPlayer: "#jquery_jplayer_1", 
            cssSelectorAncestor: "#jp_container_1"
        };
        var playlist = []; // Empty playlist
        var options = {
            swfPath: "/js", 
            supplied: "mp3"
        };
        var myPlaylist = new jPlayerPlaylist(cssSelector, playlist, options);

        $.ajax({
            url: 'process/getmusics.php',
            cache: true,
            async: false,
            type: 'post',
            data:{
                category: category,
                moodrate: rate,
            },success:function(data){
                alert(data);
                var music  = $.parseJSON(data);
                myPlaylist.add(data); 
            }


        });

PHP:

$sql = "SELECT
            `musics`.`file_name` as mp3
        FROM
            `categories`
            INNER JOIN `musics` 
                ON (`categories`.`id` = `musics`.`category`)
        WHERE (`categories`.`category_name` =?
            AND `musics`.`rate` =?)";
$result = $con->prepare($sql);
$result->bindParam(1, $category);
$result->bindParam(2, $rate);

$data=0;
if($result->execute()){
    while($r = $result->fetchAll(PDO::FETCH_OBJ)){
        $data = $r;
    }   
    echo json_encode($data);
}

现在我的ajax返回正确的数据,但问题出在我的jplayer中..

由控制台生成错误:

  

未捕获的TypeError:无法在'中使用'运营商搜索'长度'在[{" mp3":" Passenger - Let Her Go.mp3"},{" mp3":" Secondhand Serenade - Maybe.mp3&#34 ;}]

请帮助..

0 个答案:

没有答案