Jquery TokenInput not loading results

167 views Asked by At

I have:

$('.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 output:

[  
   {  
      "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"
   }
]

The code shows loading texts, but the JSON output is not renderized in text field and onResult is not fired

Thanks

1

There are 1 answers

3
plonknimbuzz On

your code not work because you write wrong syntax. if you fix it, your code will run normally now.

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

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