window.getChartScript = function getChartScript(url, chartID) {
    $.ajax({
        type: "GET",
        url: url,
        contentType: false,
        processData: false,
        dataType: "json",
        beforeSend: function () {
            $(`#${chartID}`).addClass('chart-spinner')
        },
        success: function (response) {
            eval(response.script);
            $(`#${chartID}-script`).text(response.script);
        },
        complete: function (response) {
            $(`#${chartID}`).removeClass('chart-spinner')
        },
        error: function (response) {

            $(`#${chartID}-error`).text(response.responseJSON.message);
            $(`#${chartID}-error`).parent().parent().find(".edit-chart").remove();
            $(`#${chartID}-error`).parent().parent().find(".display-report").remove();
            $(`#${chartID}-error`).parent().parent().find(".card-title >a").removeAttr("href");
        }
    });

}
