I need to pass y variable values to global array. Ajax can take json object data perfectly.
var data = [],
totalPoints = 10;
function getRandomData() {
if (data.length > 0) {
data = data.slice(1);
}
// Do a random walk
while (data.length < totalPoints) {
var y;
$.ajax({
url: 'phpHelperDoc/get_live_data.php',
type: 'POST',
data: {
authentication: "SN0000000004"
},
global: false,
async: false,
success: function(msgy) {
var day_data = JSON.parse(msgy);
y = day_data['value_1_live'];
//Need to send this y value to var data=[];
}
});
data.push(y);
}
}