写一个webhtml 页面插入1API接口代码web页面显示1个输入框并返回结果信息。接口地址:httpszyxywlapiccqqapi返回格式:json请求方式:getpost请求示例:httpszyxywlapiccqqapiqq=336699 status string 返回的状态码 phone string 绑定的号码 phonediqu string 绑定的号码的地区 mess
以下是使用HTML和JavaScript编写的一个简单的Web页面,用于显示一个输入框并返回接口的结果信息。
<!DOCTYPE html>
<html>
<head>
<title>API测试页面</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<h1>API测试页面</h1>
<input type="text" id="qqInput" placeholder="请输入QQ号">
<button onclick="getApiResult()">获取结果</button>
<div id="result"></div>
<script>
function getApiResult() {
var qq = document.getElementById("qqInput").value;
var apiUrl = "https://zy.xywlapi.cc/qqapi?qq=" + qq;
$.ajax({
url: apiUrl,
method: "GET",
dataType: "json",
success: function(response) {
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = "状态码: " + response.status + "<br>" +
"绑定的号码: " + response.phone + "<br>" +
"绑定的号码的地区: " + response.phonediqu + "<br>" +
"提示信息: " + response.message;
},
error: function() {
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = "请求失败,请重试!";
}
});
}
</script>
</body>
</html>
请将以上代码保存为一个HTML文件,然后在浏览器中打开该文件即可看到一个输入框和一个按钮。输入QQ号码后,点击按钮将会调用API接口并显示返回的结果信息
原文地址: https://www.cveoy.top/t/topic/irRW 著作权归作者所有。请勿转载和采集!