<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body>
<button onclick="getData.call(this,'http://192.168.50.42:7030/home/GetSignalRHostLink')">请求</button>
<button onclick="getData2(this,'http://192.168.50.42:7030/home/GetSignalRHostLink')">请求2</button>
<button onclick="getData3()">获取值</button>
<textarea id="t1">
</textarea>
<script>
async function getData(url) {
this.in
this.disabled = true;
const response = await fetch(url, {
method: 'GET'
});
const data = await response.json();
console.log(data)
//this.disabled=false;
}
async function getData2(e, url) {
e.disabled = true;
window.location.reload();
const response = await fetch(url, {
method: 'GET'
});
const data = await response.json();
console.log(data)
//this.disabled=false;
}
async function getData3() {
var con = document.getElementById("t1").value;
console.log(con)
var result = { "11": con }
console.log(result)
}
document.write("Hello World!")
</script>
</body>
</html>
简单的 js http 请求方式
于 2022-12-31 14:31:09 首次发布