向服务器发送多个响应



我想在按钮被点击时发送按钮的id。但是当我单击按钮时,它向服务器发送10个xhttp请求,它应该只发送一个。我无法找出问题所在。

<HTML>
<head>
<script>
function fun1(element) {
var xhttp = new XMLHttpRequest();
xhttp.open("GET", "/pre?"+element.id, true);
xhttp.send();
//alert(element.id);
}
</script>
</head>
<body>
<button type="button" onclick="fun1(this)" id="img1">IMAGE</button>
</body>
</html>

问题已经解决,我正在发送"200"收到响应后。

最新更新