-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
44 lines (41 loc) · 935 Bytes
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JQ XML With AJAX Method</title>
<style>
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
detailAjax();
});
function detailAjax(){
$.ajax({
url: "details.xml",
dataTtpe: "xml",
success: function(data){
$("ul").children().remove();
$(data).find("food").each(function(){
var allData;
allData = "<li>Name: "+$(this).find("name").text()+"</li>";
allData += "<li>Price: "+$(this).find("price").text()+"</li>";
allData += "<li>Calories: "+$(this).find("calories").text()+"</li>";
$("ul").append(allData);
});
},
error: function(){
$("ul").append("Error!");
}
});
}
</script>
</head>
<body>
<h2>JQ - XML With AJAX Method</h2>
<div class="wrap">
<ul></ul>
</div>
<br>
</body>
</html>