I need to call a web service from jQuery, when I put the breakpoint the following code is hitting, but its not reaching the web service……is there anything wrong with this code?
function searchItems() {
$("#txtSectionName").autocomplete({
source: function (request, response) {
$.ajax({
url: "/DataService.asmx/SearchSections",
data: "{'searchTerm' : '" + $("#txtSectionName").val() + "'}",
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 {
value: item.Name
}
}))
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
}
});
},
minLength: 1
});
}
You data is malformed. jQuery will take care of JSON encoding. Just pass an object: