Tabulator - Using AJAX to retrieve a JSON document

I am currently working on importing a json file from an Azure blob container using Azure Data Factory.

Despite closely following the documentation and researching various resources on Stack Overflow, I am facing challenges with making the ajax request function properly.

After overcoming CORS issues to access the json file, I now encounter a Data Loading Error:

Data Loading Error - Unable to process data due to invalid data type
Expecting: array 
Received:  undefined 
Data:      undefined

In my initial assumption, I suspected that the BOM added at the beginning of the json file before the array could be causing the issue. This suspicion arose when I noticed the BOM preceding the array in the file preview in Chrome.

Nevertheless, I have manually removed the BOM and re-uploaded the file to the blob storage, yet the error persists.

Below is my Tabulator code integrated into an HTML file for loading:

var table = new Tabulator("#example-table", {
    ajaxConfig:{
        method: 'GET',
        mode: 'cors'
    },
    ajaxURL:"https://mihndbotblob.blob.core.windows.net/mihndbot-transcripts/finalTranscripts/2019-08-07.json",
    index:"MessageID",
    autoResize:true,
    layout:"fitData",
    placeholder:"Awaiting Data...",
    columns:[
        {title:"Type", field:"Type", visible:false},
        ...
    ],

    ajaxResponse:function(url, params, response){

        return response.data;
    },

    rowClick:function(e, row){
    alert("Row " + row.getData().id + " Clicked!!!!");
    },
});

The json data loads perfectly fine when done manually as shown below:

var tableData = [
    // JSON data here
];

The structure of the json file returned by the ajax call mirrors the one above, confirmed through the Chrome preview.

I hit a roadblock in resolving the ongoing issue and would appreciate any insights or solutions to overcome it.

Answer №1

It seems that updating your ajaxResponse function with the following code snippet might be beneficial:

 ajaxResponse:function(url, params, response){
        //url - the URL of the request
        //params - the parameters passed with the request
        //response - the JSON object returned in the body of the response.

        return response.data.d; //pass the data array into Tabulator
    },

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Encountering an unexpected error with the InvalidCharacterError in IE11 when using VEE Validate in conjunction with Vue.js and babel-p

Encountering an issue in IE11 where I receive an InvalidCharacterError when attempting to validate a form using vee validate in vue.js. It seems like it might be related to a polyfill error, but I'm uncertain. I have tried debugging by removing certai ...

Showing XML image and text in Gridview sourced from JSON Data

I am encountering an issue while attempting to present both image and text data in a grid view with a 2 by 2 layout. I have successfully retrieved the data from XML using JSON. Below is my code snippet where I am encountering the problem, specifically at t ...

Using the KnockOut js script tag does not result in proper application of data binding

Being new to knockout js, I found that the official documentation lacked a complete html file example. This led me to write my own script tags, which initially resulted in unexpected behavior of my html markups. Strangely enough, simply rearranging the pos ...

What is causing my array of objects to constantly accumulate undefined elements?

My quick sort function implementation for the object users_total_likes is behaving unexpectedly. When compiled and run in the terminal or browser, it adds undefined values causing a TypeError: if(users[i][key] >= users[hi][key] && users[j][key] ...

Warning: Attempting to access a property of an invalid object in

I've been diving into PHP recently. I expected it to output 0, but oddly enough I received an error message: Notice: Trying to access property of non-object in... <?php $json = '[{"assetref":"","qty":0,"raw":0}]'; $obj = json_deco ...

Exporting inbound nodes from Keras to JSON format: inbound_nodes

I'm currently trying to wrap my head around how to interpret the JSON representation of a Keras model. The field inbound_nodes stores the inputs for each layer, but I'm puzzled by why they are nested within arrays. For instance, when there are 2 ...

Editor now releases loader for app.json

After publishing a model with texturing using the editor, I attempted to load it using JSONLoader. Despite trying different methods like ObjectLoader, the model simply does not appear on screen, indicating that there may be an important element missing. & ...

Learn the process of applying distinct CSS classes to various elements within an AJAX response

The client initiates an AJAX call via jQuery. Upon fetching data from the database, I return the response which includes the application of numerous classes and styles to various HTML tags. Unfortunately, this process results in code that appears unsightly ...

Efficiently storing and managing a plethora of diverse

Hello, I have developed a React application that interacts with my API by sending orders. Here's an example of the JSON data format: [ { "product_id":13, "quantity":2 }, { "product_id":12, "quantity":2 ...

"Encountering a glitch involving Vue.js 3, Pinia, and a centralized store

While using Pinia in a Vue.js 3 project, I encountered an issue. The problem arises when I attempt to load constant JSON structures from my backend using the file src/store/constants.store.ts // @ts-check import { defineStore } from "pinia" impor ...

I'm sorry, but your request to access the API from the React localhost has been hinder

Currently, I am delving into the world of React, a JavaScript framework. My task involves fetching a token from an API provided by this service: . To achieve this, I must include my X_CONSUMER_KEY in the request. Here is the approach I am taking using the ...

The Alert Component fails to display when the same Error is triggered for the second time

In the midst of developing a Website using Nuxt.js (Vue.js), I've encountered an issue with my custom Alert Component. I designed a contact form on the site to trigger a specialized notification when users input incorrect data or omit required fields ...

Employing Ajax for interacting with a database

I am attempting to query my database using a JavaScript function for the first time, and I am struggling to get it to work. While unsure if this is the correct approach, it is the one that I have come across. Below is a simple snippet of my HTML code: < ...

Despite the unconsumedBufferLength being 0, DataReader.loadAsync is still being completed

Working on UWP WinRT, I'm dealing with JSON stream consumption using the following code: async function connect() { let stream: MSStream; return new CancellableContext<void>( async (context) => { stream ...

Running a JavaScript file with Node.js

My node.js script is named Index.js and I also have another file called bot.js. How can I execute the bot.js file using Node.js? var fs = require('fs'); const commandFiles = fs.readdirSync('./users/commands').filter(file => file.e ...

Designing an interactive header interface using React and Material UI

My header.jsx file contains the following code: // Default Import Statements var Login = require(login.jsx) const HeaderComponent = React.createClass({ getInitialState () { return { loggedIn: false, }; }, render() { return ( ...

Unable to bring in the Firebase Firestore Colletion

When working on my next app, I encountered an error while trying to call a Firestore Collection. The specific error message that appeared when I ran the app was: FirebaseError: Firebase: Firebase App named '[DEFAULT]' already exists (app/duplicat ...

Tips for minimizing database queries for each data type

I'm currently developing an App that requires the user to input numbers into two different fields. The first field is for entering numbers, while the second field displays a calculation based on the input. Each time the user enters a number, a call to ...

Challenges with managing controllers within Directives

Currently, I am in the process of updating some code within a personal project that utilizes Angular to adhere to best practices. I have come across suggestions that the future direction of Angular involves incorporating a significant amount of functionali ...

Can you navigate between slides with JQuery?

Looking to create a website similar to . The only obstacle I am encountering is understanding the code. I prefer using JQuery over MooTools. Is there anyone who can kindly assist me by providing a demo? I want to implement the functionality of switching b ...