1

jQuery Tokeninput を使用してユーザーのメールを表示していますが、実際にはユーザーを招待しようとしています。入力テキストをクリックして電子メールを入力すると、その電子メールが存在する場合でも常に結果が表示されません。

私のJSは

  <script type="text/javascript">
    $(document).ready(function() {
    var url = "http://localhost:9000/api/customers"
       $("#members").tokenInput(url, {
           theme: "facebook"
        });
    });
  </script>

私のコントローラーアクションは

  public static Result apiCustomers(){
    List<Customer> customerList = Model.coll(Customer.class).find().toArray();
    List<String> emails = new ArrayList<String>();

    for(Customer c : customerList){
        emails.add(c.email);
    }

    ObjectNode result = Json.newObject();
    result.put("emails", Json.toJson(emails));      
    return ok(result);
  }

テキスト入力を入力すると、apiCustomer アクションが呼び出され、有効な json 文字列のような応答が返されます

{"emails":["abc@gmail.com","xyz@gmail.com","asd@gmail.com","bob@gmail.com"]} 

前もって感謝します

4

1 に答える 1

2

Tokeninput プラグインは使用していませんが、正しい json を出力していないようです。アクションが有効な json 文字列を生成している間、それはプラグインが期待する json 文字列ではありません。

正しい形式については、 Tokeninput のドキュメントを参照してください。

于 2013-01-24T23:04:31.763 に答える