I am receiving this kind of JSON object (looked up through Chrome Dev Tools):
How can I simply assign (or convert) it to the var? I mean, I would like it to become: var arr = [10, 11, 12, 13, 14, 15]
More info - this JSON object comes as AJAX response from the servlet:
EDIT:
This is how it looks now:
$(document).ready(function(){
var rrr = [];
$.ajax({
url: 'DataProvider',
type: "get",
dataType: 'json',
success: function(response) {
rrr = response;
console.log(+rrr); //output: [10, 11, 12, 13, 14, 15]
}
});
console.log(rrr); //output: [] - why is the array empty here???
var ctx = $('#myChart').get(0).getContext("2d");
var data = {
labels : ["Roll 1","Roll 2","Roll 3","Roll 4","Roll 5","Roll 6"],
datasets : [
{
fillColor : "rgba(210,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
data : rrr
}
]
}
var myNewChart = new Chart(ctx).Bar(data);
});
arr
? – Jonathan Lonowski Mar 18 '14 at 19:52