<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<button type="button" onclick="sendGet()">发送get请求</button>
</body>
</html>
<script type="text/javascript">
var xmlhttp;
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "https://autumnfish.cn/api/joke/list?num=1", true);
xmlhttp.send();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var responseText = xmlhttp.responseText;
var obj = JSON.parse(responseText);
alert(obj.jokes[0]);
}
}
</script>