I am passing data from php to js via ajax. I use json_encode before the transfer. here the example:
$data = [
[
"path" => "/TestMenu1",
"component" => 'test1',
"children" => [[
"path" => "/api/sub/route",
"component" => "test2",
]]
],[
"path" => "/api/findme/2",
"component" => "test3",
]
];
And from client side I get this without any problems:
[
{
"path": "/TestMenu1",
"component": "test1",
"children": [
{
"path": "/api/sub/route",
"component": "test2"
}
]
},
{
"path": "/api/findme/2",
"component": "test3"
}
]
But I need the components to be variable names instead string like:
[
{
"path": "/TestMenu1",
"component": test1,
"children": [
{
"path": "/api/sub/route",
"component": test2
}
]
},
{
"path": "/api/findme/2",
"component": test3
}
]
Is that possible? If yes how can I accomplish that?