Link to home
Start Free TrialLog in
Avatar of Charles Baldo
Charles BaldoFlag for United States of America

asked on

JSON data retuned from web service has "d" in front

I have a webservice in vb.net .net 4.0  that is being consumed by jQuery

The webservice is returning this (what I need)

[{value:123,label:Smith, Robert,dateString:false},{value:124,label:Smith, John,dateString:false}]

data in the jQuery function is this

{"d":"[{value:123,label:Smith, Robert,dateString:false},{value:124,label:Smith, John,dateString:false}]"}

<script type="text/javascript">
    $(function () {
        $('#txtSearch').autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: '<%=ResolveUrl("jQueryAutocomplete.asmx/GetCustomers")%>',                  
                    data: "{'prefix':'" + request.term + "'}",
                    type: 'POST',
                    contentType: 'application/json; charset=utf-8',
                    dataType: 'json',
                    success: function (data) {                          
                            response(data);
                        },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                            alert(XMLHttpRequest + '  Text Status ' + textStatus + '  Error Thrown  ' + errorThrown);
                        },
                    failure: function (response) { alert('Failure ' + response.responseText); }
                    });
            },
            minLength: 1
        }).data("ui-autocomplete")._renderItem = function (ul, item) {
            console.log(item);
            return $('<li/>')
              .attr('data-value', item.value)
              .append(item.label)
              .appendTo(ul);
        };
    });
</script>
SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Charles Baldo

ASKER

Thank you both,  Got solution and learned 2 new things