1. 程式人生 > >Ajax傳送請求,並接受字串

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