<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link href="https://fonts.googleapis.com/css2?family=Do+Hyeon&display=swap" rel="stylesheet">
</head>
<body>
<button type="button" class="btn btn-lg btn-info">xml데이터를 ajax함수를 이용하여 읽기</button>
<img alt="" src="../image/01.png">
<div id="show" class="alert alert-danger" style="width: 400px; margin-top: 30px;"></div>
<script type="text/javascript">
$("button").click(function() {
$.ajax({
type:"get",
url:"../day1014_ajax/teamtoxml.jsp",
dataType:"xml",
success:function(data){
var s="<h3>XML데이타읽기</h3>";
$(data).find("team").each(function(i,element){
var n=$(this);
s+="번호: "+n.attr("num")+"<br>";
s+="이름: "+n.find("name").text()+"<br>";
s+="운전면허: "+n.find("driver").text()+"<br>";
s+="주소: "+n.find("addr").text()+"<br>";
s+="작성일: "+n.find("writeday").text();
s+="<hr>";
});
$("#show").html(s);
}
});
});
</script>
</body>
</html>
'Ajax' 카테고리의 다른 글
211015_xml,json파일 ajax로 읽기 (0) | 2021.10.15 |
---|---|
211015_db 생성후 JSONObject를 생성해서 json파일 만들기 (0) | 2021.10.15 |
211015_db생성하여 jsp에서 json으로 변환후 ajax로 불러오기 (0) | 2021.10.15 |
211015_ (0) | 2021.10.15 |
211015_json 데이터를 ajax함수로 읽기 (0) | 2021.10.15 |