<html>
<head>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.5.1.min.js"></script>
<script>
$(document).ready(function(){
$(document).ajaxError(function(){
alert("An error occured!");
});
$("button").click(function(){
$("div").load("wrongfile.txt");
});
});
</script>
</head>
<body>
<div><h2>让 AJAX 更改此文本</h2></div>
<button>更改内容</button>
</body>
</html>