方法1:后台封装json数组:(outputJSON是封装好的方法,具体有好多类型)
public void selectProte() {
JSONObject result = new JSONObject();
JSONArray result11 = new JSONArray();
for (int i = 1; i < 11; i++) {
JSONObject json = new JSONObject();
json.put("dd", i + "value" + i);
result11.add(json);
}
result.put("result", result11);
this.response.outputJSON(result11);
}
html页面js:
function selectButt(){
alert("555");
$.ajax({
url : "${path}/admin/ythGuidance/receiptExperienceBaseRecord/selectProte.action",
dataType : "json",
cache : false,
success : function(data) {
var json=eval(data);
$.each(json, function (index, item) {
var s1 = json[index].dd;
alert("s1:"+s1);
}
)
}
});
}