I'm creating dynamic dropdown lists from values in my database. I'm querying the data, creating a php variable in this format:
$items = array(
'red'=>'apples,firetrucks,blood',
'yellow'=>'bus,pencil,duck'
);
I can then use the json_encode()
function to encode.
{
"red":"apples,firetrucks,blood",
"yellow":"bus,pencil,duck",
}
I know the getJson
is passed at file or a path like:
$.getJSON("jsondata/data.json", function(data) {
Can my json variable be passed to this function instead? The reason I want a variable to be passed, rather than a file is because my data can chance on a daily basis, ie:
$items = array(
'red'=>'apples,firetrucks,bricks',
'yellow'=>'bus,pencil,duck'
);