我目前正试图在我的控制台中获取来自Dropbox API的响应数组。我想得到那个数组,以便我将它显示在我的JStree中.. 我尝试使用console.log(fulltree.entries)来显示数组,结果是console.log我希望在我的控制台中获取该数组以显示在我的jstree中
$(function() {
var fullTree;
var url = 'https://api.dropboxapi.com/1/delta';
var access_token = 'My ACCESS TOKEN IN DROPBOXAPI';
$.ajax({
url: url,
data: fullTree,
method: "POST",
dataType: "json",
beforeSend: function(request) {
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader("Authorization", 'Bearer ' + access_token);
},
success: function(fullTree) {
$('#container').jstree({
'core': {
"data": fullTree.entries,
"check_callback": true,
},
"plugins": ["themes", "contextmenu", "ui","icon"]
});
console.log(fullTree.entries);
},
error: function(xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(thrownError);
}
});
});
答案 0 :(得分:1)
将数组转换为字符串,然后使用console.log()。
console.log(JSON.stringify(fullTree.entries));
希望这会有所帮助。