Ajax傳送請求,並接受字串
阿新 • • 發佈:2019-02-07
前臺:
$.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());