最後の部分が機能しない次のコードがあるため、私の質問が発生します.JPlayerのプレイリストの一部が宣言されていません
(function($) {
Drupal.behaviors.MyfunctionTheme = {
attach: function(context, settings) {
$('.add-music').click(function() {
var songNew = JSON.stringify({
title: $(this).attr('data-title'),
artist: $(this).attr('data-artist'),
mp3: $(this).attr('href')
});
var songIE = {
json: songNew
};
$.ajax({
type: 'POST',
data: songIE,
datatype: 'json',
async: true,
cache: false
}).done(
//this is the callback function, which will run when your POST request returns
function(postData) {
//Make sure to test validity of the postData here before issuing the GET request
var session;
$.ajaxSetup({
cache: false
})
$.get('/getsession.php', function(getData) {
session = JSON.parse(getData);
var myPlaylist = new jPlayerPlaylist({
jPlayer: "#jquery_jplayer_N",
cssSelectorAncestor: "#jp_container_N"
}, [session], {
playlistOptions: {
enableRemoveControls: true
},
swfPath: "../js",
supplied: "oga, mp3"
});
});
});
});
}
}
})(jQuery);
私が得る問題は、プレイリスト「未定義」に参加することです
セッション変数には以下が含まれます
{"title":"radio novela wagia. CAPITULO 1","artist":"","mp3":"http://red.comppa.com/sites/default/files/audios/radionovela%20wagia%20final.mp3"},{"title":"radio novela wagia. CAPITULO 1","artist":"","mp3":"http://red.comppa.com/sites/default/files/audios/radionovela%20wagia%20final.mp3"},{"title":"Lenguas Indígenas en Los Medios de Comunicación","artist":"","mp3":"http://red.comppa.com/sites/default/files/audios/Cun%CC%83aLenguasIndigenasEnMediosdeComunicacion.mp3"}
しかし、次のテストを実行すると、完全に機能します
(function ($) {
Drupal.behaviors.MyfunctionTheme = {
attach: function(context, settings) {
var session = [{"title":"radio novela wagia. CAPITULO 1","artist":"","mp3":"http://red.comppa.com/sites/default/files/audios/radionovela%20wagia%20final.mp3"},{"title":"radio novela wagia. CAPITULO 1","artist":"","mp3":"http://red.comppa.com/sites/default/files/audios/radionovela%20wagia%20final.mp3"},{"title":"Lenguas Indígenas en Los Medios de Comunicación","artist":"","mp3":"http://red.comppa.com/sites/default/files/audios/Cun%CC%83aLenguasIndigenasEnMediosdeComunicacion.mp3"}];
var myPlaylist = new jPlayerPlaylist({
jPlayer: "#jquery_jplayer_N",
cssSelectorAncestor: "#jp_container_N"
}, session, {
playlistOptions: {
enableRemoveControls: true
},
swfPath: "../js",
supplied: "oga, mp3"
});
}}
})( jQuery );
説明や助けをありがとうございました