$.ajax({
type: "POST",
url: "${contextPath}/test/list.do",
dataType: "json",
data: "clevel="+clevel+"&catcode="+pcatcode,
success: changeResult2
});
function changeResult2(oj){
try
{
var json = eval(oj);
if (json.length>0){
var clevel = json[0].clevel;
for (var i=0;i<json.length;i++){
$("#p_cate_cd"+eval(clevel)).append("<option value='"+json[i].catcode+"' etc='"+json[i].etc+"' ordby='"+json[i].ordby+"'>"+json[i].catname+"</option>");
}
}
$("#p_cate_cd"+clevel).val($("#catcode").val()).attr("selected","selected");
} catch (err) {
alert("예외 오류입니다." + err);
}
}
[{"catcode":"506100", "clevel":"2", "pCatcode":"506", "catname":"타사", "catcode1":"506", "catcode2":"100", "catcode3":"", "catcode4":"", "catcode5":"", "catcode6":"", "matchcode":"", "etc":"", "ordby":"62", "isuse":"0"}, {"catcode":"506101", "clevel":"2", "pCatcode":"506", "catname":"자사", "catcode1":"506", "catcode2":"101", "catcode3":"", "catcode4":"", "catcode5":"", "catcode6":"", "matchcode":"", "etc":"", "ordby":"63", "isuse":"0"}, {"catcode":"506102", "clevel":"2", "pCatcode":"506", "catname":"우루사", "catcode1":"506", "catcode2":"102", "catcode3":"", "catcode4":"", "catcode5":"", "catcode6":"", "matchcode":"", "etc":"", "ordby":"64", "isuse":"0"}, {"catcode":"506103", "clevel":"2", "pCatcode":"506", "catname":"테스트", "catcode1":"506", "catcode2":"103", "catcode3":"", "catcode4":"", "catcode5":"", "catcode6":"", "matchcode":"", "etc":"", "ordby":"65", "isuse":"0"}, {"catcode":"506104", "clevel":"2", "pCatcode":"506", "catname":"서비스업체", "catcode1":"506", "catcode2":"104", "catcode3":"", "catcode4":"", "catcode5":"", "catcode6":"", "matchcode":"", "etc":"", "ordby":"66", "isuse":"0"}, {"catcode":"506105", "clevel":"2", "pCatcode":"506", "catname":"사랑의실", "catcode1":"506", "catcode2":"105", "catcode3":"", "catcode4":"", "catcode5":"", "catcode6":"", "matchcode":"", "etc":"", "ordby":"67", "isuse":"0"}, {"catcode":"506106", "clevel":"2", "pCatcode":"506", "catname":"정보사", "catcode1":"506", "catcode2":"106", "catcode3":"", "catcode4":"", "catcode5":"", "catcode6":"", "matchcode":"", "etc":"", "ordby":"68", "isuse":"0"}]
public static void printJSONValue(HttpServletResponse response, MyBuilderDescriptor mybuilderData) throws Exception {
response.setContentType("application/x-json; charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
ZValue zvl = null;
JSONArray jsonArray = new JSONArray();
String[] arr_colm = mybuilderData.getSbColum().toString().split(MyBuilderUtil.col);
String[] arr_data = mybuilderData.getSbData().toString().split(MyBuilderUtil.row);
int len_colm = arr_colm.length;
int len_data = arr_data.length;
for (int i=0; i<len_data ; i++){
for (int j=0; j<len_colm ; j++){
String[] arr_dataColm = arr_data[i].split(MyBuilderUtil.col);
zvl = new ZValue();
zvl.put(arr_colm[j], arr_dataColm[j]);
}
jsonArray.add(zvl);
}
log2.debug(jsonArray.toString());
response.getWriter().write(jsonArray.toString());
}
'JQuery' 카테고리의 다른 글
[JQuery] ajax 예제3 (0) | 2022.05.19 |
---|---|
[JQuery] ajax POST방식 (0) | 2022.05.18 |
[JQuery] ajax json 예제 2 (0) | 2022.05.18 |
[JQuery]ajax (0) | 2022.04.19 |
[JQuery]현재 페이지 URL 및 변수 가져오기 (0) | 2022.04.19 |