首页 > Web开发 > 详细

Ajax && json(原始)

时间:2017-05-10 10:33:25      阅读:256      评论:0      收藏:0      [点我收藏+]
function findSend() {
        $.ajax({
//            async: false,
//            cache: true,
            type: "POST",
            url: "InMessageServlet?action=findSend",
            data: $(‘#receiveForm‘).serialize(),// 你的formid
            dataType: ‘json‘,
//            error: function(request) {

//            },
            success: function (data) {
//                alert(data.success);
//            window.location.href = "InMessageServlet?action=one";

            }
        });
    };
public void findSend(HttpServletRequest request, HttpServletResponse response) throws Exception {

List<InMessage> list = new ArrayList<InMessage>();
InMessage im = new InMessage();
。。。。。。
list.add(im);
JSONArray json = new JSONArray();
for (InMessage a : list) {
JSONObject jo = new JSONObject();
jo.put("mainMessage", a.getMainMessage());
jo.put("sendUserName", a.getSendUserName());
json.put(jo);
}
request.setCharacterEncoding("utf-8");
response.setContentType("text/json");
PrintWriter out = response.getWriter();

out.print(json);
out.flush();
out.close();
}



  

Ajax && json(原始)

原文:http://www.cnblogs.com/jwlfpzj/p/6834591.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!