Skip to content

Commit a8b2cfe

Browse files
committed
JS3test
1 parent 1c03673 commit a8b2cfe

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

Week1/hw/script.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function fetchJSON(url){
2+
let xhr = new XMLHttpRequest();
3+
xhr.open('GET', url);
4+
xhr.responseType = 'json';
5+
xhr.onreadystatechange = () => {
6+
if (xhr.readyState === 4) {
7+
if (xhr.status < 400) {
8+
return (xhr.response);
9+
} else {
10+
console.log('failled') ;
11+
}
12+
}
13+
};
14+
xhr.send();
15+
}
16+
17+
18+
19+
let value = fetchJSON('http://api.nobelprize.org/v1/prize.json?year=2017');
20+
console.log(value);

Week1/hw/test.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>HYFJ3W1</title>
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flexboxgrid/6.3.1/flexboxgrid.min.css">
9+
<script src="script.js"></script>
10+
</head>
11+
<body >
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)