使用ajax,如何在页面端将返回数据提取出来

action端:

public void chuancan() throws Exception{
HttpServletRequest request = ServletActionContext.getRequest();
String leibie = request.getParameter("leibie");
String neir = request.getParameter("neir");
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/html;charset=utf-8");
String a = leibie + ":"+ neir;
response.getWriter().write(a);

}

页面端:

function hdfjd(){
  
  $.ajax({
              url : "${pageContext.request.contextPath}/visitcustomer_chuancan.action",
              type : "post",
              data : $("#chuan").serialize(),
              success:function(data){//ajax返回的数据
              var value=data.split(":");
              var leibie = value[0];
              var neir = value[1];
              $('#grid').datagrid({ url: "visitcustomer_pageQuery.action?leibie="+leibie+"&neir="+neir }); 
               }
  });
}


你可能感兴趣的:(备着)