I'm currently working on updating a jqplot chart dynamically using Ajax requests. The server is sending back the data in the form of a string like this:
"[['Juice',30],['Milk',30],['Water',30]]"
However, I need to convert this string into an array of arrays. Can anyone confirm if this is the correct method for updating the data and, if so, what is the most effective way to perform the conversion?
$.ajax({
url:'http://localhost',
success:function(plotData){
var data = plotData.split(",");
if(plot){
plot.series[0].data = data;
plot.redraw();
}
},
fail:function(error){
alert('error:'+error);
}
});
The code provided converts the string into a one-dimensional array with these elements:
0: "[['Helpdesk'" 1: "30]" 2: "['Users'" 3: "30]" 4: "['Auto Generated'" 5: "30]]"