#http://192.168.1.1:8000/?B=AABBCC&data=
这个是固定值。=后面是需要输入的值。
输入后回车可以在后台访问一次,不需要跳转。然后可以接着输入接着回车,重复循环。
用html或者php该怎么写呢?
求各位老板帮忙
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
</style>
</head>
<body>
<div id="div">
<input type="" name="" id="input" value="" />
</div>
</body>
<script>
document.onkeydown = function(e){
var value = document.getElementById("input").value;
if(e.keyCode === 32){
let url = "http://192.168.1.1:8000/?B=AABBCC&data="+value
console.log(value) // 参数
console.log(url) // 地址
// 访问
}
}
</script>
</html>
$url = "http://192.168.1.1:8000/?B=AABBCC&data=" . $_GET['data'];
$result = file_get_contents( $url );
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Title</title>
<style></style>
</head>
<body>
<div id="div">
<input type="" name="" id="input" value="" onkeydown="enter(event)" />
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
function enter(e) {
var evt = window.event || e;
if (evt.keyCode == 13) {
//回车后要干的业务代码
var value = document.getElementById("input").value;
let url = "http://192.168.1.1:8000/?B=AABBCC&data=" + value;
console.log(value); // 参数
console.log(url); // 地址
$.get(url, function (data) {
console.log("发送给后端之后的回调");
});
}
}
</script>
</body>
</html>