b.jsp
=============================================
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(document).ready(function(){
$("#b").click(function(){
$.ajax({
url:"a.jsp",
dataType:"json",
cache:false,
success:function(data){
var str="";
str+="ID:"+data.member.id;
str+="PW:"+data.member.pw;
str+="ADDR:"+data.member.addr;
str+="TEL:"+data.member.tel;
$("#con").html(str);
}
});
});
});
</script>
<body>
<input type="button" id="b" value="회원정보보기">
<div id="con"></div>
</body>
</html>
a.jsp
============================================
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%@ page import="java.util.*" %>
<%@ page import="kr.co.seoulit.member.dao.*" %>
<%@ page import="kr.co.seoulit.member.to.*" %>
<%@ page import="net.sf.json.*"%>
<%
MemberDAO dao=MemberDAOImpl.getInstance();
MemberBean member=dao.selectMember("id3");
HashMap<String,Object> map=new HashMap<String,Object>();
map.put("member",member);
JSONObject jsonObject= new JSONObject();
jsonObject.putAll(map);
out.println(jsonObject);
%>
'개발하자 > ajax&json' 카테고리의 다른 글
dataType:'json',$.getJSON,$.parseJSON (0) | 2015.03.03 |
---|---|
텍스트박스에 id치고 정보보기 클릭하면 db정보 보임 (0) | 2015.03.03 |
id,pw,addr,tel출력하기 (json) (0) | 2015.03.03 |
json2 error (0) | 2015.03.03 |
json 값뽑아내기 (0) | 2015.03.03 |