Skip to content
This repository was archived by the owner on May 30, 2021. It is now read-only.

Adding a column from a remote source

Karl edited this page Sep 1, 2017 · 8 revisions

Adding a column from a remote source (AJAX) is simple with the columns() API.

{
    heading: "Progress"
    data: [
        "37%",
        "97%",
        "63%",
        "30%",
        ...
    ]
}
var getData = function() {
	
    var columnData = "remote/data/url";

        var xhr = new XMLHttpRequest();	
	
        xhr.addEventListener("load", function(e) {
            if (xhr.readyState === 4) {
                if (xhr.status === 200) {
                    table.columns().add(JSON.parse(xhr.responseText));
                }
            }
        });

        xhr.open('GET', columnData);
        xhr.send();
}

Clone this wiki locally