mike chambers | about

Adding custom query argument support to jQuery Autocomplete plugin

I have been playing around with the jQuery Autocomplete plugin to get it working with the ActionScript 3 documentation API that I posted about earlier today.

The Autocomplete API is really nice, and pretty flexible, but one issue I ran into is that the query argument containing the user input that is passed to the server is hard coded to “q”. For my api, I needed this argument to be “api”.

The fix is actually pretty simple, although it does require a slight modification to the jquery.autocomplete.js file.

Here is a diff that shows the change for the AutoComplete library version 1.0.2:

You can then pass in the value that should be use for the query term like so:

var url = "http://as3reference.appspot.com/getapi?version=flex3";
$("#example").autocomplete(url, {

If the queryArgument is not specified, then it defaults back to “q”.

It looks like this feature will be added in the next release.

Ill post the complete example working with the API shortly.

twitter github flickr behance