ajax-如何在我的控制台日志中获取数组?

问题描述 投票:0回答:1

我目前正试图在我的控制台中获取来自我的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);
        }
    });
}); 
javascript arrays ajax
1个回答
1
投票
  1. 将数组转换为字符串,然后使用console.log()。 console.log(JSON.stringify(fullTree.entries)); 希望这会有所帮助。
© www.soinside.com 2019 - 2024. All rights reserved.