2016-07-08 10 views
-1

私はビューエンジンとしてThymeleafを使用しています。Thymeleaf Jquery構文エラー

Jqueryスクリプトが構文エラーをスローします。

コントローラは非常にうまく動作しているので、私はここに投稿しませんでした。ここで

ここでコード

<!DOCTYPE HTML> 
<html xmlns:th="http://www.thymeleaf.org"> 
<head> 
<title>Add Author</title> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<link rel="stylesheet" href="../public/bootstrap-3.3.6-dist/css/bootstrap.css" th:href="@{/bootstrap-3.3.6-dist/css/bootstrap.css}"/> 
<script src="../public/jquery/jquery-3.0.0.min.js" th:src="@{/jquery/jquery-3.0.0.min.js}"></script> 


</head> 
<body> 
<h1>Add New Author</h1> 
<div class="col-lg-3" > 
<form class="addAuthorForm" role="form" action="#" th:action="@{/author/new-author}" th:object="${addNewAuthor}" method="post"> 

<div th:class="form-group" th:classappend="${#fields.hasErrors('phone')}? 'has-error'"> 
    <label>Phone</label> 
    <input class="form-control" type="text" th:field="*{phone}" placeholder="Enter author's phone number"/> 
    <p th:if="${#fields.hasErrors('phone')}" class="label label-danger" th:errors="*{phone}">Phone Error</p> 
</div> 

<button type="submit" class="btn btn-default">Add</button> 
<button type="reset" class="btn btn-default">Reset</button> 

</form> 
</div> 

<script type="text/javascript"> 
$(document).ready(function() { 

    $(".addAuthorForm").validate(
      { 
       rules: { 
        name: { 
         required : true, 
         remote : { 
          url: "<spring:url value='/author/isexist.html'/>", 
          type: "get", 
          data: { 
           phone: function() { 
            return $("#phone").val(); 
           } 
          } 
         } 
        } 
       }, 

       messages: { 
        name: { 
         remote: "Phone number already exists!" 
        } 
       } 
      } 
    ); 
}); 
</script> 

</body> 
</html> 

である私がここに間違っているかを理解していない

enter image description here

、エラーです。あなたの指導を求める。

+0

「これが 『正しい』答えです」、あなたはjavascriptのデバッグに関するいくつかの基本的なチュートリアルを実行する必要があります。 –

答えて

1

引用符の種類を混在させる必要があります。それは

単一の文字列になるように、単一引用符と内部のものを交換してください。これは非常に基本的な構文エラーです

+0

これは、url: "と書かれています。 – Tareq