I can't figure out how to build the array of objects from the string I return from an ajax call.
Let's say I return a string:
{name:"Claus", age:39};;{name: "Tom", age:42};;{name: "John",age: 13}
This string is contained in the variable returnData.
I have an array called jsData which I want to be a collection of objects and I would like the result to look like the following:
jsData[0] = {name:"Claus", age:39}
jsData[1] = {name:"Tom", age:42}
jsData[2] = {name:"John",ag e:13}
What I can't figure out is how to do that. I tried to use :
var jsData = returnData.spli t(;;)
I also tried to add [ ] to the beginning and end of the string that was returned to returnData, but that did not work either.
I do not wish for "name" and "age" to be constants, they will vary with each ajax query as will the total number of records returned.
I am trying to build a multi-purpose module that will display a table for me which I can use with my varied apps.
Let's say I return a string:
{name:"Claus", age:39};;{name: "Tom", age:42};;{name: "John",age: 13}
This string is contained in the variable returnData.
I have an array called jsData which I want to be a collection of objects and I would like the result to look like the following:
jsData[0] = {name:"Claus", age:39}
jsData[1] = {name:"Tom", age:42}
jsData[2] = {name:"John",ag e:13}
What I can't figure out is how to do that. I tried to use :
var jsData = returnData.spli t(;;)
I also tried to add [ ] to the beginning and end of the string that was returned to returnData, but that did not work either.
I do not wish for "name" and "age" to be constants, they will vary with each ajax query as will the total number of records returned.
I am trying to build a multi-purpose module that will display a table for me which I can use with my varied apps.
Comment