Charles Baldo
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:Smit h, John,dateString:false}]
data in the jQuery function is this
{"d":"[{value:123,label:Sm ith, Robert,dateString:false},{ value:124, label:Smit h, John,dateString:false}]"}
<script type="text/javascript">
$(function () {
$('#txtSearch').autocomple te({
source: function (request, response) {
$.ajax({
url: '<%=ResolveUrl("jQueryAuto complete.a smx/GetCus tomers")%> ',
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") ._renderIt em = function (ul, item) {
console.log(item);
return $('<li/>')
.attr('data-value', item.value)
.append(item.label)
.appendTo(ul);
};
});
</script>
The webservice is returning this (what I need)
[{value:123,label:Smith, Robert,dateString:false},{
data in the jQuery function is this
{"d":"[{value:123,label:Sm
<script type="text/javascript">
$(function () {
$('#txtSearch').autocomple
source: function (request, response) {
$.ajax({
url: '<%=ResolveUrl("jQueryAuto
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")
console.log(item);
return $('<li/>')
.attr('data-value', item.value)
.append(item.label)
.appendTo(ul);
};
});
</script>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER