Json
: javaScript 객체와 유사한 형식으로 데이터를 표현하고 교환하는 경량 데이터 형식
xml
: 태그를 사용하여 데이터를 표현
http://sample.bmaster.kro.kr/contacts?pageno=3&pagesize=10
<script>
$(document).ready(function() {
// 자바스크립트 객체를 json형태로 바꾸기
var person = {
name : "홍길동",
age : 30
}
var json = JSON.stringify(person); // 기본적으로 String으로 바꿔줌
document.write(json + "<br>");
$.ajax({
type : "GET",
url : "https://sample.bmaster.kro.kr/contacts?pageno=3&pagesize=10" , // 제이슨서버
async : false, // 비동기 함수 : 이걸 쓰면 통신 성공이 먼저 나옴
success : function(result){
console.log("통신 성공");
console.log(result);
document.write(result.pageno);
document.write(result.contacts[0].name);
},
error : function(error){
console.log(error);
}
});
console.log("비동기 체크 문구"); // '통신 성공'보다 얘부터 출력
});
</script>
</head>
<body>
<table id="list-table" width="500" border="1"></table>
</body>