Requesting Help with simple jQuery AutoComplete code


I am trying to build a simple autoComplete functionality for a website.

This scary looking URL is my Web Service to query ><Search Characters>

e.g. if q=cancer, I get back:

{"text":"cancer research","score":12.60096},
{"text":"cancer biology","score":12.593915},


So I am trying to use jQueryUI to display the returned results (i.e. "text" under the searchBox, as described here>

But I need to change the data source to the Web Service above. To help me code that, I found this>

My attempt to code this is below, but I still need to figure out what the following quote means, & how to do it!
e.g. I am struggling to know what this line does> data: { q: request.term } << Where does 'request.term' come from
Any help would be much appreciated.

your code will look similar to the above except you'll just call response(data) in the success handler. In other words, since you are changing the default AJAX request that takes place, you'll still have to do it yourself.

<!doctype html>
<html lang="en">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>jQuery UI Autocomplete - Default functionality</title>
    <h1>AutoComplete / AutoSuggest jQuery Demo</h1>

    <link rel="stylesheet" href="//">
    <!--  <link rel="stylesheet" href="/resources/demos/style.css">  -->
    <script src=""></script>
    <script src=""></script>

            source: function (request, response) {
                    url: "",
                    data: { q: request.term },
                    success: function (data) {
                        var transformed = $.map(data, function (el) {
                            return {
                                label: el.text,
                                id: el.score
                    error: function () {


<div class="ui-widget">
    <label for="tags">Tags: </label>
    <input id="tags">



The API documentation for the source option, shows that the request object has a single property called term which contains the value in the text field. In your case, request.term would be a string of "cancer".

closed #3

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.