The value of the Easyui drop-down box is the JSON format chestnut:
The wording of the front desk:
function Querydes () { $ (' #des '). ComboBox ({ ' businessbaseinfo/querydes.action ', Valuefield:' enmdatopt ', // value textField: ' enmdatdes ' / / what the foreground drop-down box displays }); }
The URL gets the JSON format, the data here is in the background wrapped JSON format, can be directly obtained:
[ { "enmdatdes": "Pig on behalf of the butcher", "enmdatopt": "2001" }, { "enmdatdes ":" Hog Dealer ", " enmdatopt ":" 2002 " }, { " enmdatdes ":" Live sheep Dealer " , "enmdatopt": "2022" }, { "enmdatdes": "All", " Enmdatopt ":" " }]
There is also a background JSON does not conform to the rules, my practice is that the foreground parse JSON, and then repack the data such as:
{ "ErrorCode": 10000, "ErrorMsg": "Operation succeeded", "List": [ { "Enmcnnam": "Flow node Type", "Enmdatdes": "Slaughter Factory", "Enmdatlen": "4", "Enmdatopt": "0001", "Enmennam": "NODETYPE", "Enmno": "1", "Sysid": "1000", "Sysnam": "Meat dish system" }, { "Enmcnnam": "Flow node Type", "Enmdatdes": "Supermarket", "Enmdatlen": "4", "Enmdatopt": "0004", "Enmennam": "NODETYPE", "Enmno": "11", "Sysid": "1000", "Sysnam": "Meat dish system" }, { "Enmcnnam": "Flow node Type", "Enmdatdes": "Group consumption unit", "Enmdatlen": "4", "Enmdatopt": "0005", "Enmennam": "NODETYPE", "Enmno": "12", "Sysid": "1000", "Sysnam": "Meat dish system" } ]}
The foreground accepts JSON and parses, the foreground drop-down box data needs to be Enmdatdes and enmdatopt These two, then wraps these two :
var stuarrayobjs = [];function Querydes () {$.ajax ({URL:' Common/finddiclist?enmennam=nodetype ', DataType:"JSON", type:"POST", Success:function (data) {var obj=eval (data); for(Var i=0;i<obj.list.length;i++) {var stuarrayobj= {}; stuarrayobj["Enmdatdes"] =Obj.list[i].enmdatdes; stuarrayobj["Enmdatopt"] =obj.list[i].enmdatopt; Stuarrayobjs.push (Stuarrayobj); } //var teachcoursejsonstring = json.stringify (STUARRAYOBJS); Note this, the data for the dropdown box is not for this $(' #des1 '). ComboBox ({DATA:STUARRAYOBJS, Valuefield:' Enmdatopt ',//values to be passed back to the platformTextField: ' Enmdatdes '//what the foreground drop-down box displays }); } }); }
So it's done.
Easyui drop-down box to get the value