views:

1287

answers:

2

Well I have a 50000+ row table so I can't load all rows into each page for the user to use autocomplete, so I am trying to use an ajax call via the extraParams parameter but don't know:

1) What format to make the results display in on the page being called via ajax (get-dropdown-results.xml in this case)

2) How to get these results into the dropdown

Here's my current source:

$("input#autocomplete-field").autocomplete(
    "/ajax/get-dropdown-results.xml",{
    delay:0,
    minChars:3,
    matchContains:true,
    matchSubset:false,
    max:100,
    extraParams: {
        q: function () { return escape($("input#autocomplete-field").val()); }
    }
});

I am running firebug so I can see the ajax calls are being made correctly (/ajax/get-dropdown-results.xml?q=whatever-they-typed) but I don't know where to put code to handle the returned text.

+2  A: 

I assume that you use jQuery autocomplete plugin by Dylan Verheul. This plugin will create drop-down popup for you automatically. However it expects results to be in plain text format, not XML. Try returning results separated by line ends:

foo\n
bar\n
baz\n
Pavel Chuchuva
Thanks, once this worked the rest was easy
Andrew G. Johnson
A: 

hope this will help JQuery AutoComplete using XML with Key Value pair http://aspdotnetpatterns.blogspot.com/2009/08/jquery-autocomplete-using-xml-with-key.html