Ajax发送请求,并接受字符串

前台:
        $.ajax({
              type: 'POST',
              url: url,
              dataType: "json",
              success : function(data){
                  alert("success:"+data+"-"+data.length);
              },
              error : function(mes){
                  alert("error:"+mes);
              }
        });
③返回字符串
List list = ……
String json = JSONArray.fromObject(list).toString();
response.setContentType("text/html;charset=utf-8");
response.getWriter().write(json.toString());
posted @ 2018-05-31 23:40  滕鹏飞  阅读(2234)  评论(0编辑  收藏  举报