{"action":"created","issue":{"url":"https://api.github.com/repos/Pixabay/jQuery-autoComplete/issues/30","labels_url":"https://api.github.com/repos/Pixabay/jQuery-autoComplete/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/Pixabay/jQuery-autoComplete/issues/30/comments","events_url":"https://api.github.com/repos/Pixabay/jQuery-autoComplete/issues/30/events","html_url":"https://github.com/Pixabay/jQuery-autoComplete/issues/30","id":98344905,"number":30,"title":"provide example with suggestions for AJAX","user":{"login":"nekromoff","id":8550349,"avatar_url":"https://avatars.githubusercontent.com/u/8550349?v=3","gravatar_id":"","url":"https://api.github.com/users/nekromoff","html_url":"https://github.com/nekromoff","followers_url":"https://api.github.com/users/nekromoff/followers","following_url":"https://api.github.com/users/nekromoff/following{/other_user}","gists_url":"https://api.github.com/users/nekromoff/gists{/gist_id}","starred_url":"https://api.github.com/users/nekromoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nekromoff/subscriptions","organizations_url":"https://api.github.com/users/nekromoff/orgs","repos_url":"https://api.github.com/users/nekromoff/repos","events_url":"https://api.github.com/users/nekromoff/events{/privacy}","received_events_url":"https://api.github.com/users/nekromoff/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-31T08:49:06Z","updated_at":"2015-07-31T09:14:49Z","closed_at":null,"body":"there is no example provided for AJAX and the example is not descriptive enough\r\n\r\nsource: function(term, suggest){\r\n        try { xhr.abort(); } catch(e){}\r\n        var suggestions = [];\r\n        xhr = $.getJSON('randomsearch.php', { q: term }, function(data){ $('#searchquery').text(term); renderitems(data); });\r\n    },\r\n\r\nhow should be suggestions vs choices and matches handled in this case? this is not explained properly as all the suggestion examples are only given for the static list of choices."},"comment":{"url":"https://api.github.com/repos/Pixabay/jQuery-autoComplete/issues/comments/126618284","html_url":"https://github.com/Pixabay/jQuery-autoComplete/issues/30#issuecomment-126618284","issue_url":"https://api.github.com/repos/Pixabay/jQuery-autoComplete/issues/30","id":126618284,"user":{"login":"SimonSteinberger","id":1267443,"avatar_url":"https://avatars.githubusercontent.com/u/1267443?v=3","gravatar_id":"","url":"https://api.github.com/users/SimonSteinberger","html_url":"https://github.com/SimonSteinberger","followers_url":"https://api.github.com/users/SimonSteinberger/followers","following_url":"https://api.github.com/users/SimonSteinberger/following{/other_user}","gists_url":"https://api.github.com/users/SimonSteinberger/gists{/gist_id}","starred_url":"https://api.github.com/users/SimonSteinberger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SimonSteinberger/subscriptions","organizations_url":"https://api.github.com/users/SimonSteinberger/orgs","repos_url":"https://api.github.com/users/SimonSteinberger/repos","events_url":"https://api.github.com/users/SimonSteinberger/events{/privacy}","received_events_url":"https://api.github.com/users/SimonSteinberger/received_events","type":"User","site_admin":false},"created_at":"2015-07-31T09:14:49Z","updated_at":"2015-07-31T09:14:49Z","body":"`renderItem` and its use is explained in \"Advanced suggestions handling and custom layout\" - the example with the country names. All you have to do to make this work with Ajax, is replacing the static list of choices/suggestions with an Ajax call that returns a list of suggestions in the following format:\r\n`var suggestions = [['Australia', 'au'], ['Austria', 'at']];`\r\nAfter having received this array via Ajax, run the callback `suggest(suggestions);`."}}