htmlCopy code
<!DOCTYPE html>
<html>
<head>
<title>Random Joke Generator</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<h1>Random Joke Generator</h1>
<button id="getJoke">Get Joke</button>
<p id="joke"></p>
<script>
$(document).ready(function(){
$("#getJoke").click(function(){
$.ajax({
url: "https://official-joke-api.appspot.com/random_joke",
type: "GET",
success: function(data) {
$("#joke").html(data.setup + "<br>" + data.punchline);
},
error: function(error) {
console.log(error);
}
});
});
});
</script>
</body>
</html>