json 打印

1 JsonObject jsonObj = new JSONObject();
2 jsonObj.put("success",true);
3 jsonObj.put("msg","成功");
4 
5 PrintWriter out = response.getWriter();
6 out.print(jsonObj);
7 out.close();

后台简单代码  前台如果是ajax:

$.ajax({ url: "test.html", context: document.body, success: function(jsonObj){
        $(this).addClass("done");
      }});
posted @ 2017-02-07 09:21  懒得像猪  阅读(656)  评论(0编辑  收藏  举报