-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAjax-class.html
More file actions
32 lines (31 loc) · 954 Bytes
/
Ajax-class.html
File metadata and controls
32 lines (31 loc) · 954 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test Page</title>
</head>
<body>
<h1 id="h1_1">This is a test page</h1>
<div id="div1"></div>
<script src="js/jquery-3.5.1.js"></script>
<script>
(function () {
"use strict"
$().ready(function () {
$.ajax("data/colors.json").done(function(data, status, jqXhr) {
alert("AJAX call completed successfully!");
console.log("Request status: " + status);
console.log("Data returned from server:");
console.log(data);
let html = '';
for (let dataItem of data) {
html += `<div>${dataItem.color} value is ${dataItem.value}</div>`;
console.log(dataItem.color); // dataItem['color']
console.log(dataItem);
}
$('#div1').html(html);
});
});
})();
</script>
</body>
</html>