Error handling when exporting to a server

Export and print

by Flexmonster Pivot Table

HTML

<script src="https://cdn.flexmonster.com/flexmonster.js"></script>

<p>The output will appear <a href="#output">under the component</a>.</p>

<button onclick="exportTo()">Export to server</button>

<div id="pivot-container"></div>

<div class="output" id="output">Output will appear here</div>

CSS

@import url(https://cdn.flexmonster.com/assets/jsfiddle-styles.css);

JavaScript

let pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  height: 260,
  report: {
    dataSource: {
      filename: "data/data.csv"
    }
  }
});

function exportTo() {
  pivot.exportTo('csv', {
      destinationType: 'server',
      url: 'http://httpstat.us/404'
    },
    function(result, error) {
      showOutput(JSON.stringify(error, null, 4));
    }
  );
}

function showOutput(content) {
  document.getElementById("output").innerText = content;
}