Autocompleter.Remote

docs

This class comes with two methods for retrieving data from the local domain: XHTML and Json.

Autocompleter.Ajax.Json

Autocompleter.Ajax.Json will send a query to your specified url with the data the user enters and transform the response (which must be in Json format) into the suggestions for you. The usage is the same as the local version of Autocompleter except it has a few extra optoins related to the request.

new Autocompleter.Ajax.Json($('ajaxJson'), 'server/auto.php' {
  postVar: 'query',
  postData: {}, //additional key/value sets to send with the request
  ajaxOptions: {} //additional settings passed to the instance of Request
});

Autocompleter.Ajax.Xhtml

The XHTML version is very similar to the Json example above. In addition to all the examples illustrated above, you must pass in a function to parse the response:

new Autocompleter.Ajax.Xhtml($('ajaxXhtml'), 'server/auto.php', {
  postData: {html: 1}, //some data to go along with the request
  //handle the data returned
  injectChoice: function(el) {
    var value = el.getFirst().get('html');
    el.inputValue = value;
    this.addChoiceEvents(el).getFirst().set('html', this.markQueryValue(value));
  }
});

cnet-libraries/11-3rdparty/03-autocompleter.remote.txt · Last modified: 2008/11/17 23:25 by aaron-n