You probably have synchronization issues.
Dad is an asynchronous library, a signal sign is the fact that offers a complete callback.
This means that you cannot use a global variable to pass your results from A to B. In fact, you should avoid global variables at all.
All the work that you want to do after the result is ready must be done in the callback function. This applies to any asynchronous process in JavaScript.
function handleFileSelect(evt) { if ( !(evt.target && evt.target.files && evt.target.files[0]) ) { return; } Papa.parse(evt.target.files[0], { header: true, dynamicTyping: true, complete: function (results) { debugDataset(results); renderDataset(results); } }); } function debugDataset(dataset) { var formatted = JSON.stringify(dataset, null, 2); $("<div class='parse'></div>").text(formatted).appendTo(".graphcontainer"); } function renderDataset(dataset) {
source share