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());

你可能感兴趣的:(JavaWeb)