{"action":"created","issue":{"url":"https://api.github.com/repos/twitter/typeahead.js/issues/1508","repository_url":"https://api.github.com/repos/twitter/typeahead.js","labels_url":"https://api.github.com/repos/twitter/typeahead.js/issues/1508/labels{/name}","comments_url":"https://api.github.com/repos/twitter/typeahead.js/issues/1508/comments","events_url":"https://api.github.com/repos/twitter/typeahead.js/issues/1508/events","html_url":"https://github.com/twitter/typeahead.js/issues/1508","id":151210447,"number":1508,"title":"Ajax without bloodhound doesnt works","user":{"login":"csimpi","id":6192067,"avatar_url":"https://avatars.githubusercontent.com/u/6192067?v=3","gravatar_id":"","url":"https://api.github.com/users/csimpi","html_url":"https://github.com/csimpi","followers_url":"https://api.github.com/users/csimpi/followers","following_url":"https://api.github.com/users/csimpi/following{/other_user}","gists_url":"https://api.github.com/users/csimpi/gists{/gist_id}","starred_url":"https://api.github.com/users/csimpi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csimpi/subscriptions","organizations_url":"https://api.github.com/users/csimpi/orgs","repos_url":"https://api.github.com/users/csimpi/repos","events_url":"https://api.github.com/users/csimpi/events{/privacy}","received_events_url":"https://api.github.com/users/csimpi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-26T18:46:45Z","updated_at":"2016-05-08T15:29:31Z","closed_at":null,"body":"Please somebody give me an example.\r\nI would like to make similar then facebook new message user search javascript.\r\n\r\nI tried to so many ways ajax source, but it isnt works. I get the suggestions from database, it returns an array inside some objects. The objects contains multiple values (id,name,profile_img).\r\nUnfortunatelly typehead didnt shows up the suggestions. Why? I use displayKey option.\r\n\r\nI would tike to use typeahed with tagsinput js.\r\n\r\n```\r\n    var elt = $(\".user-search\");\r\n    var where = $(this).data('where');\r\n    \r\n    elt.tagsinput({\r\n        itemValue: 'id',\r\n        itemText: 'name',\r\n        freeInput: false\r\n    });\r\n\r\n    elt.tagsinput('input').typeahead(null, {\r\n        displayKey: 'name',\r\n        minLength: 1,\r\n        source: function(query, process) {\r\n            // do your Ajax call here\r\n            return $.get({\r\n                url: \"/api/users/search\",\r\n                data: {'term':query,'where':where},\r\n                dataType: \"json\"\r\n            }).done(function(msg) {\r\n                        console.log('DONE:',msg[1]);\r\n                        \r\n                return process(msg[1]);\r\n            }).fail(function(jqXhr, textStatus) {\r\n                alert(\"Request failed: \" + textStatus);\r\n            });\r\n        }\r\n    }).bind('typeahead:selected', $.proxy(function (obj, selectedItem) {\r\n        // add tag to tagsinput plugin\r\n        this.tagsinput('add', selectedItem);\r\n        // reset input of tagsinput plugin\r\n        this.tagsinput('input').typeahead('val', '');\r\n        // handle when user selects tag here\r\n    }, elt));\r\n\r\n    elt.on('itemRemoved', function (event) {\r\n        // handle when user removes tag here\r\n    });\r\n```"},"comment":{"url":"https://api.github.com/repos/twitter/typeahead.js/issues/comments/217727076","html_url":"https://github.com/twitter/typeahead.js/issues/1508#issuecomment-217727076","issue_url":"https://api.github.com/repos/twitter/typeahead.js/issues/1508","id":217727076,"user":{"login":"einfallstoll","id":619048,"avatar_url":"https://avatars.githubusercontent.com/u/619048?v=3","gravatar_id":"","url":"https://api.github.com/users/einfallstoll","html_url":"https://github.com/einfallstoll","followers_url":"https://api.github.com/users/einfallstoll/followers","following_url":"https://api.github.com/users/einfallstoll/following{/other_user}","gists_url":"https://api.github.com/users/einfallstoll/gists{/gist_id}","starred_url":"https://api.github.com/users/einfallstoll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/einfallstoll/subscriptions","organizations_url":"https://api.github.com/users/einfallstoll/orgs","repos_url":"https://api.github.com/users/einfallstoll/repos","events_url":"https://api.github.com/users/einfallstoll/events{/privacy}","received_events_url":"https://api.github.com/users/einfallstoll/received_events","type":"User","site_admin":false},"created_at":"2016-05-08T15:29:31Z","updated_at":"2016-05-08T15:29:31Z","body":"The first can't work because you're calling the synchronous callback, the second can't work because you're synchronously returning a value that gets set asynchronously."}}