0
返回JSON可变我有功能:我无法从jQuery的AJAX功能
function get_playlist(){
var result = jQuery.ajax({
url: '<?php echo admin_url('admin-ajax.php'); ?>',
type: 'post',
dataType: 'json',
data: {
action: 'getrandommp3',
nonce:'<?php echo wp_create_nonce('randmp3'); ?>'
},
success: function(response) {
console.log(response); // All OK!
window.response = response;
var customvar = response;
return response;
}
});
console.log(window.response); // undefined
console.log(result.responseText); //undefined
console.log(customvar); //undefined
return window.response; // returning undefined
}
我需要从函数返回JSON变量。里面有success: function(response) {
响应有需要的内容。但Jquery.ajax
我有问题外...
此代码需要jQuery的MP3播放器...
var playlist = get_playlist();
var myPlaylist = new jPlayerPlaylist(cssSelector, playlist, options);
myPlaylist.shuffle(true, true);
感谢您的帮助!
我有jquery播放器,我需要返回json mp3的清单。 'var playlist = get_playlist(); \t \t \t var myPlaylist = new jPlayerPlaylist(cssSelector,playlist,options); \t \t \t myPlaylist.shuffle(true,true);' – 2012-03-12 10:01:50
然后在'success'事件处理程序中创建'jPlayer'。看我的编辑。 – 2012-03-12 10:03:20
谢谢你的帮助) – 2012-03-12 10:08:28