java返回字符串給ajax請求

$.ajax ({
			async   :   xx,
			url		:	xx,
		    type 	: 	xx,
		    data	:	xx,
		}).done (function(e,data) {
			//返回數據到這裏
console.log('這是獲得的字符串'+e);
		});

那麼服務端能夠這樣寫ajax

//這裏是HttpServletResponse
String sonFoldersInfo = "Hello World!";
resp.setContentType("text/plain");
resp.setCharacterEncoding("UTF-8");
resp.getWriter().write(sonFoldersInfo);
相關文章
相關標籤/搜索