I can't return my json object
问题 I'm having trouble returning a JSON object, instead all I get is an undefined variable. This code is supposed to return a json element from an API. It seems to work in the success: function, but once I try and take that data elsewhere it just displays 'undefined' var datas; datas = getdata(); //getdata(); createChart(datas) alert('2datass'+datas); // this returns undefined function createChart(data){ alert(data); //outputs undefined } function getdataaa(){ alert('ajax'); $.ajax({ type: "GET",