You have to make sure, that your server returns valid JSON. This would be a flat array (number-indexed) with dictionary-styled arrays as items. Here's a probable sample;
<?php
//requestServerData.php
$data = array();
$item_one = array("name" => "state1", "id" => "s1");
$item_two = array("name" => "state2", "id" => "s2");
array_push($item_one);
array_push($item_two);
echo json_encode($data);
?>
Putting it together with the fiddle you provided, simulating XHR via requestServerData function, this is how it goes:
// global handles for the store and combobox
var combo = null, store = null;
// simulaition of a call to PHP server, which returns a json encoded array
// e.g. "[{name:'state1', id:'s1'},{name:'state2', id:'s2'}]"
function requestServerData() {
var responseText = "[{name:'state1', id:'s1'},{name:'state2', id:'s2'}]";
var data = eval(responseText);
var newStore = new dojo.store.Memory({"data": data});
combo.set('store', newStore);
combo.set('value', data[0].name)
}
// since domReady is in the require, this code block is not run until page loads
require([
"dojo/store/Memory", "dijit/form/ComboBox", "dojo/domReady!"
], function(Memory, ComboBox){
store = new Memory({
data: [
{name:"Loading", id:"LOAD"}
]
});
combo = new ComboBox({
id: "stateSelect",
name: "state",
value: "Loading",
store: store,
searchAttr: "name"
}, "stateSelect");
combo.startup();
requestServerData()
});
Your fiddle, updated: https://jsfiddle.net/fuanzcps/3/
new Memory({Data:responseServer}), give the php code to have look inside your code - Spring