Quiero enviar la identificación del botón cuando se hace clic en el botón. Pero cuando hago clic en el botón, envía 10 solicitudes xhttp al servidor, debería enviar solo una. No soy capaz de averiguar el problema.
<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>Se solucionó el problema, envío el "200" después de recibir la respuesta.