Jquery TokenInput 未加载结果



我有:

$('.titulares').tokenInput("http://localhost/ajax/ajax.php",{
            tokenLimit: 1,
            queryParam: 'query',
            propertyToSearch: 'nome',
            resultsLimit: 2,
            tokenValue: 'id',
            noResultsText: 'Nada',
            searchingText: "Procurando...",
            hintText: "Buscar titular",
            method: 'GET',
            onResult(){
                alert('a');
            }           
        });

ajax.php JSON 输出:

[  
   {  
      "id":12,
      "nome":"Joe Bill"
   },
   {  
      "id":13,
      "nome":"PJ"
   },
   {  
      "id":14,
      "nome":"John"
   },
   {  
      "id":16,
      "nome":"Acme"
   },
   {  
      "id":17,
      "nome":"Acme2"
   },
   {  
      "id":18,
      "nome":"Acme3"
   }
]

代码显示加载文本,但 JSON 输出不会在文本字段中呈现,并且不会触发 onResult

谢谢

你的代码不起作用,因为你写了错误的语法。 如果你修复它,你的代码现在将正常运行。

onResult: function(result){
                console.log(result);
            } 

演示:http://jsbin.com/yimiwumije/edit?html,js,output

最新更新