I have some Dojo datagrids to which I want to pass a JSON object. This is so the grids can iterate through the JSON data on their formatter events.
I think I am able to create the JSON object this way:
$stmt = sqlsrv_query($connection,$query);
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC))
{
$arr[] = $row;
}
echo '{"sample":'.json_encode($arr).'}';
This echos the JSON data to the screen (which, of course, is not what I want). I want to be able to create a Javascript object which I can refer to in my Dojo Javascript event called by my Dojo scripts.
I hope I'm making sense here. Trying to work between PHP (server side) and JS (client side) is still pretty new to me.
I need to somehow turn my bit of code above into something that will create a JS object that I can use in the JS in my header to allow it to iterate through creating a table.
How can I do this?