After making an Ajax call, the response.responseText I receive looks like this:
.
"[
columns :[
{
"id":"name",
"header":"User name"
},
{
"id":"birth",
"header":"Date of birth"
}
],
data :[
{
"id":1,
"firstname":"Adam",
"lastname":"Smith"
},
{
"id":2,
"firstname":"Tom",
"lastname":"Brown"
},
]
]"
My question now is, how do I separate the columns
and data
and store them into two different variables?
When attempting to do this in the success function of my code, like so:
success: function(conn, response, options, eOpts) {
JSON.parse(conn.responseText);
}
I encounter the following error: VM23977:2 Uncaught SyntaxError: Unexpected token c in JSON at position 8 at JSON.parse ()
Can someone please advise on how to resolve this issue.