0

我正在尝试从 API 获取一些数据并加载到数据表(datatable.net)中。我已经按照指南完成了代码,它根本没有加载。

AJAX 成功完成请求。

下面的代码:

function loadTable(api) {
$.ajax({
    url: api,
    type: 'GET',
    dataType: 'json',
    "dataSrc": "",
    beforeSend: function () {
        console.log('\"Data collection\" query operation triggered')
        $(".overlay").show(); //We are showing loading spinner here
    },
    headers: { Authorization: 'Basic XXXX },
    success: function (data, textStatus, xhr) {
        //Populate Table            
        $('#datatable').DataTable({
            "columns": [
                { "data": "DataObjectName" },
                { "data": "SourceObject" },
                { "data": "IndnexType" },
                { "data": "ObjectType" },
                { "data": "FeedType" },
                { "data": "BusinessUnit" },
                { "data": "VersionId" },
                { "data": "Unit" },
                { "data": "Unit" },
            ],
            "bDestroy": true
        })
        console.log('\"Data collection\" query operation succesfully completed');
    },
    error: function (xhr, textStatus, errorThrown) {
        console.log('\"Data collection\" query operation failed. Error : ' + errorThrown);
        showNotification('top', 'right', 'Error while performing ' + operation + '. Error : ' + errorThrown, 'danger');

    },
    complete: function () {
        $(".overlay").hide(); //We are showing loading spinner here
        console.log('\"Data collection\" query operation task completed');
    }
});

}

4

0 回答 0