I am having trouble trying to figure out how to use JQuery Autocomplete in the following situation.
I am trying to hook it up to a Web Service that returns a JSON object. The URL form is the following:
host/api/schools/{search-term}
No query-string ?term= or anything else.
How can I set up Autocomplete to do this? I’m pretty new at JavaScript, but I can get by.
I’ve tried the following bit:
$(...).autocomplete({
source: function(term, callback) {
$.getJSON("url", { foo: term }, callback);
}
});
but can’t quite get it to pass host/api/schools/{search-term} to the server (it comes out as host/api/schools/?foo%5Bterm=%5D{search-term} when checked using fiddler where {search-term} is the text entered.
Help?
Adding this here as it basically answers the question, from the jquery-ui documentation: