1.基本写法
function a2() {
$.ajax({
url:"${pageContext.request.contextPath}/ajax",
type:"POST",
data:{name:"前台好帅得程序员"},
success:function(data){
console.log(data);
}
});
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
String attribute = (String) request.getParameter("name");
response.getWriter().print("好帅的程序员!"); //返回页面对应data值
}