JQuery AutoComplete (jQuery UI 1.8rc3) with ASP.NET Web Service

I currently have this version of autocomplete control working when returning XML from an .ashx handler. Xml looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?> 
<States>
<State>
  <Code>CA</Code> 
  <Name>California</Name> 
</State>
<State>
  <Code>NC</Code> 
  <Name>North Carolina</Name> 
</State>
<State>
  <Code>SC</Code> 
  <Name>South Carolina</Name> 
</State>

The autocomplete code is as follows:

    $('.autocompleteTest').autocomplete(
    {
        source: function(request, response) {
            var list = [];
            $.ajax({
                url: "http://commonservices.qa.kirkland.com/StateLookup.ashx",
                dataType: "xml",
                async: false,
                data: request,
                success: function(xmlResponse) {
                    list = $("State", xmlResponse).map(function() {
                        return {
                            value: $("Code", this).text(),
                            label: $("Name", this).text()
                        };
                    }).get();
                }
            });
            response(list);
        },
        focus: function(event, ui) {
            $('.autocompleteTest').val(ui.item.label);
            return false;
        },
        select: function(event, ui) {
            $('.autocompleteTest').val(ui.item.label);
            $('.autocompleteValue').val(ui.item.value);
            return false;
        }

    });

For various reasons, I prefer to call the ASP.NET web service, but I cannot get it to work. To go to the service (I'm doing a local service to make it simple), start the autocomplete code:

    $('.autocompleteTest').autocomplete(
    {
        source: function(request, response) {
            var list = [];
            $.ajax({
                url: "/Services/GeneralLookup.asmx/StateList",
                dataType: "xml",

This code is located on the page at the root of the site, and GeneralLookup.asmx is located in a subfolder named Services. But the breakpoint in the web service never hits, and no auto-complete list is created. In case it matters, the XML that comes from asmx:

<?xml version="1.0" encoding="utf-8" ?> 
<string xmlns="http://www.kirkland.com/"><State> <Code>CA</Code> <Name>California</Name> </State> <State> <Code>NC</Code> <Name>North Carolina</Name> </State> <State> <Code>SC</Code> <Name>South Carolina</Name> </State></string>

, node . jQuery .asmx , .ajax - .ajax, ?

.asmx(~/Services/), , . .

?

+5
1

.asmx JSON. , :

JavaScript:

$("#tbNameFilter").autocomplete({
    source: function (request, response) {
        $.ajax({
            url: "/Services/AutocompleteService.asmx/Aoi_Autocomplete",
            data: "{ 'q': '" + request.term + "', 'limit': '10' }",
            dataType: "json",
            type: "POST",
            contentType: "application/json; charset=utf-8",
            dataFilter: function (data) { return data; },
            success: function (data) {
                response($.map(data.d, function (item) {
                    return {
                        label: item.Name,
                        value: item.Name
                    }
                }))
            }
        });
    },
    minLength: 1
});

-:

[WebMethod]
public List<FAD_Aoi> Aoi_Autocomplete(String q, int limit)
+17

All Articles