title: Call javascript function in thymeleaf
body: <p>I need to call a javascript function inn thymeleaf and I am getting an error as function is not defined.
  Here's my code </p>
  
  <pre><code>&lt;div class="input-field col s6 m6"&gt;
          &lt;input id="isbn" name="isbn" type="text" class="validate" /&gt;
          &lt;label for = "isbn"&gt;Enter ISBN Code&lt;/label&gt;
  &lt;/div&gt;
      &lt;div class="input-field col s6 m6"&gt;
          &lt;button id="submitCode" class="btn waves-effect waves-light col m4" th:onclick="'javascript:myFunction();'" value="data"&gt;ISBN Data&lt;/button&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>Javascript Code</p>
  
  <pre><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;&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);
  }
  </code></pre>