No, request or response not reserved keywords - if they were, you could not use them as function parameter names ..
What happens here is pretty simple, and if you ever do something in Node, you'll see a template. This is asynchronous JavaScript.
You pass the anonymous function source . This function is called whenever autocomplete requires a data source request (in other words, the user typed something).
Parameters of the request and response function. request is just a request to autocomplete information; request.term is the request (that the user typed). It is up to you how to implement the search - perhaps you have a local variable with capabilities or you can make an AJAX call to the server.
Now the important part: if you make an AJAX call, you cannot just return value from source() , because the function will return long before the AJAX call ends. This is why the response parameter exists.
response is a reference to the function passed to your source() function, which you call whenever you have a response to the request. Thanks to the magic of closures, you can call this function from an AJAX callback.
response (which is called callback with the least confusion) expects an array of strings or objects with label and value properties. It will display these results in the autocomplete drop-down list.
Putting it all together:
$('selector').autocomplete({ ... source: function(request, response) {
josh3736
source share