I can't seem to get the JSON results to populate to the input after the data is returned from the server. This is the post function I am using and it is giving me well a formed JSON string. From what I understand from the docs, the response that is returned is what should be populating to the input, but is not in my case.
$('#employeeSearch').typeahead({
source:function(query, process) {
return $.post('employee.asp', {query:query}, function(data) {
return data;
}, 'json');
}
});
Here is the sample string being returned from the server:
[{"name":"Jody Masters","id":"18"}]
What am I missing here?
Try this one:
$.post('employee.asp', { query: query }, function(data) {
$('#employeeSearch').typeahead({
source: data
});
}, 'json');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.