title: jquery: autocomplete with remote xml source
body: <p>I am trying to implement an autocomplete textbox whose values are generated by a remote script returning XML contents. I'm using JQuery-1.4.3 and the autocomplete widget from JQuery-UI-1.8.5.</p>
  
  <p>I've studied the autocomplete demo page for the <a href="http://jqueryui.com/demos/autocomplete/xml.html" rel="nofollow">XML data parsed once</a> example, and am trying to implement the comments:</p>
  
  <blockquote>
    <p>This should also serve as a reference on how to parse a remote XML datasource - the parsing would just happen for each request within the source-callback.</p>
  </blockquote>
  
  <p>As a test, I'm trying to get this working with the supplied XML demo. Above comment suggests that the autocomplete 'source' property has to be replaced with the Ajax call. Yet, when I modify this in the function supplied at the <a href="http://jqueryui.com/demos/autocomplete/xml.html" rel="nofollow">demo page</a>, I'm not getting any results with following autocomplete function:</p>
  
  <pre><code>$( "#birds" ).autocomplete({
    source: function(request, response) {
      $.ajax({
        url: "london.xml",
        dataType: "xml",
        success: function( xmlResponse ) {
          var data = $( "geoname", xmlResponse ).map(function() {
  //alert($('name', this).text());
            return {
              value: $( "name", this ).text() + ", " +
                     ( $.trim( $( "countryName", this ).text() ) || "(unknown country)" ),
              id: $( "geonameId", this ).text()
            };
          }).get();
        }
      })
    },
    minLength: 0,
    select: function( event, ui ) {
      log( ui.item ?
           "Selected: " + ui.item.value + ", geonameId: " + ui.item.id :
           "Nothing selected, input was " + this.value );
    }
  });
  </code></pre>
  
  <p>Still, commenting out the simple debug popup message shows that the Ajax call does manage to retrieve the values used in constructing the data. Where's my mistake?</p>
  
  <p>Any help much appreciated!</p>
  
  <p>Kind regards,</p>
  
  <p>Ron Van den Branden</p>