//JS文件 $("#category").ready(function(){ $.ajax({ type:"POST",url:"sdkactivity/getCategoryList.ac",success:function(data){ if(data.result=="true"){ varreturndata=data.resultData; varganmeInfo=returndata.split(","); $("#category").empty(); for(vari=0;i<ganmeInfo.length;i++){ varaGame=ganmeInfo[i].split(":"); varui="<optionvalue='"+aGame[0]+"'>"+aGame[1]+"</option>"; $("#category").append(ui); } } } }); });
//页面代码 <selectid="category"name="category"style="width:200px;"></select>
//action代码 Map<String,String>resultMap=getMessageMap(); List<MpgameSdkCategory>categorys=this.commonService.findList(MpgameSdkCategory.class,Integer.MAX_VALUE,null,Factor.create("deleted",C.Eq,0),Factor.create("fkGameId",gameId)); StringresultData=""; for(MpgameSdkCategorycategory:categorys){ if(resultData==""){ resultData=category.getId()+":"+category.getName(); } else{ resultData=resultData+","+category.getId()+":"+category.getName(); } } resultMap.put("result","true"); resultMap.put("resultData",resultData);