java ,action
public void print(String rs){
		PrintWriter out;
		try {
			HttpServletResponse response = ServletActionContext.getResponse();
			response.setContentType("text/plain");
			response.setCharacterEncoding("UTF-8");
			out = response.getWriter();
			// 获取分类数据
			out.print(rs);
			out.flush();
			out.close();
		} catch (IOException e) {
//			LogUtil.errorLog(TAG, "print", e);
		}
}

print("[{"proCode":"10241101","sellerId":"1001"},{"proCode":"10241101","sellerId":"1002"},{"proCode":"10241102","sellerId":"1001"}];")

  

后台拼成json格式,通过ajax接收返回结果,

$.ajax({
		url : "utilAction.action", 
		type : "GET", 
		data : "service=showProduct",
		success : function(result) {
			var products = eval(result);// 转换为json对象
			var datatable = "<table>";
			for ( var i in products) {
				datatable = datatable + "<tr><td>" + products[i].proCode + "</td><td>"
						+ products[i].sellerId+"</td></tr>";
			}
			datatable = datatable + "</table>";
			$("#mainDIV").html(datatable);

		}
	});

  

 

相关文章:

  • 2022-03-09
  • 2022-02-09
  • 2022-12-23
  • 2021-07-16
  • 2022-12-23
  • 2021-09-28
  • 2022-12-23
猜你喜欢
  • 2021-10-26
  • 2022-02-09
  • 2021-07-08
  • 2021-06-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案