2016-12-09 3 views
0

Ich muss eine Javascript-Funktion in Thymoleaf aufrufen und ich bekomme einen Fehler als Funktion ist nicht definiert. Hier ist mein CodeRufen Sie Javascript-Funktion in Thymoleaf

<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-Code

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

bitte teilen Sie die komplette Fehlerprotokoll entnehmen kann, dass die identifizieren helfen Problem. –

Antwort