jquery data type xml
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>필터</title>
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
type:"GET",
url:"http://localhost:8080/JqueryTest/TEST.xml",
dataType:"XML",
success:function(xml){
var name=$(xml).find("name").text();
var age = $(xml).find("age").text();
var makeHtml ="";
makeHtml +="<em> name : "+name+"</em></br>";
makeHtml +="<em> age : "+age+"</em>";
alert(makeHtml);
$("#ajaxResult").append(makeHtml);
}, error: function(xhr,status,error){
alert(error);
}
});
});
</script>
</head>
<body>
<form id="form" name="form">
<table>
<tr>
<td>
<p>AJAX DataType : XML</p>
</td>
</tr>
</br>
<tr>
<td><span id="ajaxResult"></span></td>
</tr>
</table>
</br>
<table>
<tr>
<td>
$(document).ready(function(){ </br>
$.ajax({ </br>
type:"GET", //사용할 메소드</br>
url:"http://localhost:8080/JqueryTest/TEST.xml", //요청 URL</br>
dataType:"xml", //응답의 결과로 반환되는 데이터종류 </br>
success:function(xml){ </br>
var name=$(xml).find("name").text();</br>
var age = $(xml).find("age").text();</br>
var makeHtml ="";</br>
makeHtml +="<em> name : "+name+"</em>";</br>
makeHtml +="<em> age : "+age+"</em>";</br>
alert(makeHtml);</br>
$("#ajaxResult").append(makeHtml);</br>
},</br>
error: function(xhr,status,error){ </br>
alert(error); </br>
} </br>
}); </br>
}); </br>
</td>
</tr>
</table>
</form>
<table id="table2">
<tr>
<td><a href="index.jsp">돌아가기</a></td>
</tr>
</table>
</body>
</html>