I'm using Charts.js, I wonder how to convert a string of comma separated values into data array.
There a response data, it would return (I already coded for formatting):
100.00
65.89
244.47
244.46
314.99
320.30
314.99
319.63
Then I save this data as var after of AJAX response (with jQuery):
var dataComissions;
$.each(data.orders, function(i, item) {
var dataComissions = data.orders[i].commission;
});
This data has line break each value, I need excepted result like this as one string with commas:
100.00, 65.89, 244.47, 244.46, 314.99, 320.30, 314.99, 319.63
EDIT: These answers that I'm not looking, because I can't get one var with separated values, I need to convert it.
This is console.log what i got
I need to convert this response data into a var like this:
320.30, 100.00, 65.89, 65.89, 65.89, 244.47, 244.46 ...
EDIT 2: Request data was used with:
$.getJSON( "orders/list", function( data, status ) {
}).done(function(data) {
$.each(data.orders, function(i, item) {
console.warn(data.orders[i].commission); //This is from screenshot
var dataComissions = data.orders[i].commission;
});
@Vega
var commisions = [];
$.getJSON( "phrapi/orders/list", function( data, status ) {
}).done(function(data) {
// console.warn(data.orders[0].created_at);
var commisions = [];
$.each(data.orders, function(i, item) {
commisions.push(item.commision);
});
console.log(commisions.join(', '));
});
result of console: