2016-12-09 20 views
0

javascript関数inn thymeleafを呼び出す必要があり、関数が定義されていないためエラーが発生しています。 は、ここに私のコードですthymeleafでjavascript関数を呼び出す

<div class="input-field col s6 m6"> 
     <input id="isbn" name="isbn" type="text" class="validate" /> 
     <label for = "isbn">Enter ISBN Code</label> 
</div> 
    <div class="input-field col s6 m6"> 
     <button id="submitCode" class="btn waves-effect waves-light col m4" th:onclick="'javascript:myFunction();'" value="data">ISBN Data</button> 
    </div> 

Javascriptのコード

function myFunction() 
{ 
    var isbn = document.getElementById('isbn').value; 
    alert(isbn); 
    var xmlhttp = new XMLHttpRequest(); 
    var url = "https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn; 
    xmlhttp.onreadystatechange = function() 
    { 
     if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) 
     { 
      var x = JSON.parse(xmlhttp.responseText); 
      callback(x); 
     } 
    }; 
    xmlhttp.open("GET", url, true); 
    xmlhttp.send(); 
} 
function callback(x) 
{ 
    //do things with your data here 
    alert(JSON.stringify(x)); 
    console.log(x); 
} 
+0

に参照することができます試してみてくださいかもしれませ識別するのに役立ちます、完全なエラーログを、共有してください問題。 –

答えて

関連する問題