I have a List of List that is converted into a string, passed through a GET function, and retrieved by AJAX.
Is it possible to get that string to behave like an array of arrays?
I've tried a random smattering of conversions, JSON.parse, using substring to remove the quotations, right now I'm looking at converting the variable prototype. The string is always treated as a string even tho it looks something like this on console.log(data)
data = [[27, 'category', 'item, 10, 11, 25, 30, 76], [28, 'category', 'item, 20, 25, 45, 60, 150]
//AJAX CALL
function clientDataAjax() {
$.ajax({
url : 'clientJobChartData.html',
type: "get", //send it through get method
data: {
clientName: 'Ver-a-fast'
},
success : function(data) {
/* $('#result').html(data); */
clientUsageByJobByMonth = data.slice(1, data.length-1);
//addDataset(clientUsageByJobByMonth);
console.log(clientUsageByJobByMonth);
console.log(JSON.parse(data));
}
});
}
// GET METHOD
@RequestMapping(value = "/clientJobChartData", method = RequestMethod.GET)
public @ResponseBody
String pullClientData(String clientName){
List<List<String>> clientData = chartDao.clientAndJobUsage(clientName);
String stringOfClientData = "'"+clientData+"'";
return stringOfClientData;
}
I was hoping that I could turn the string into an Array format and then be able to work with it as an array if there is a way to change the variable type.
Sorry if this is a silly question or dumb method. I'll be looking into creating JSON objects of the data I need to try and get around this. Thanks!
>` and use `JSON.parse()` in the front end.
– StaticBeagle Jul 09 '19 at 18:24