var list = [['foo', 12], ['bar', 6], ['asd', 2], ['bar', 6], ['gert', 10]]; //document.getElementById('my_canvas').innerHTML = 'test'; //WordCloud(document.getElementById('my_canvas'), { list: list } ); console.log(list); var oReq = new XMLHttpRequest(); // New request object oReq.onload = function() { //var weightFactor = function() // This is where you handle what to do with the response. // The actual data is found on this.responseText var list = JSON.parse(this.responseText); console.log(list); var options = {}; options.list = list; options.shuffle = true; options.rotateRatio = 0.5; options.weightFactor = 50; options.minSize = 4; options.drawOutOfBound = true; options.backgroundColor = 'rgba(255, 255, 255, 0)'; options.color = 'random-light'; WordCloud(document.getElementById('my_canvas'), options ); }; var urlParams = new URLSearchParams(window.location.search); var id = urlParams.get('id'); oReq.open("get", "get.php?id=" + id, true); oReq.send();