ボタンクリックが発生したときにAJAXを使用してバックエンドにjsオブジェクトを送信しようとしていますが、ボタンのクリックが機能していないようです。私はかなりJSに新しく、誰かが間違っていることに気づくことができるかどうか疑問に思っていました。JavaScriptのボタンのクリックリスナーを修正する方法
$(document).ready(function() {
annotations = []
anno.addHandler('onAnnotationCreated', function(annotation) {
annotations.push(annotation)
});
document.getElementById('done').addEventListener('click', function() {
alert("works");
});
});
<html>
<head>
<title>Poster 1</title>
<link rel="stylesheet" type="text/css" href="{{url_for('static',filename='css/main.css') }}">
<link rel="stylesheet" type="text/css" href="{{url_for('static',filename='css/annotorious.css') }}">
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous">
</script>
<script type="text/javascript" src="{{ url_for('static', filename='js/annotorious.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static', filename='js/main.js') }}"></script>
</head>
<body>
<div class="container">
<img class="annotatable" height="600" width="400" id="canvas" src="{{ url_for('static', filename='images/1.jpg') }}"></img>
<a href="{{url_for('poster2')}}">Next Poster</a>
<button type="button" id="done" onclick="onDoneClick()">Done</button>
</div>
</body>
<script type="text/js" src="js/main.js"></script>
</html>
私はjqueryのは、コンソールに正しくロードされていることをチェックしました。私はcdn – Senginel
を使用してコードUは、フルコードurを使用して質問に投稿されますか? – xF4B
また、Annotations配列を自分のコードで印刷できるので、annoが動作すると確信しています。私は使用しているAPIを含めるためにhtmlを編集しました – Senginel