본문 바로가기

개발하자/ajax&json

dataType:'json',$.getJSON,$.parseJSON

세가지방법 다 써도 됨

$.ajax({
  url:'t2.jsp',
  dataType:'json',
  success:function(data){
  alert(data.member.id+","+data.member.pw);
  }
  });

 

 

 

$.getJSON('t2.jsp',function(data){
  alert(data.member.id+","+data.member.pw);
  });

 

 

 

<%@ 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>
$.ajax({
url:"t2.jsp",
success:function(data){
var obj=$.parseJSON(data);
alert(obj.member.id+","+obj.member.pw);
}
});
</script>