<!DOCTYPE html>
<html lang=”zh-cn”>
<head>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<meta http-equiv=”X-UA-Compatible” content=”ie=edge”>
<title>ajax调用内涵段子</title>
<style>
video{
background-color: aquamarine;
}
</style>
<script src=”https://www.jb51.net/jquery-3.6.0.js”></script>
<script>
$(document).ready(function () {
xhttp=new XMLHttpRequest();
https=”https://api.apiopen.top/getJoke?page=1&count=2&type=video”;
xhttp.onreadystatechange=function(){
if(xhttp.readyState==4&&xhttp.status==200){
$(“h1”).html(JSON.parse(xhttp.responseText).result[0].text);
}
else{
}
}
$(“button”).click(function(){
xhttp.open(“GET”,https,true);
xhttp.send();
})
});
</script>
</head>
<button>点击获取</button>
<h1></h1>
<body>
</body>
</html>