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