フロントAjaxにてバックグラウンド返却データを取得
Javaバックグラウンドで検索したデータをJSONにする
フロントAjax
List tempList=new ArrayList();
JSONArray json = JSONArray.fromObject(tempList);// json
try {
response.setContentType("text/html;charset=UTF-8");// utf-8
PrintWriter out = response.getWriter();
out.print(json);
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
フロントAjax
$.ajax({
url:Url,
data:{checkname:enco,categoryId:cateId},// ,
type:"get",
traditional:true,
success : function(data){
eval("var mydata="+data);
$.each(mydata,function(i,item){
alert(item.Id+"=="+item.Name);
}); } });