$('#<%= txtSearch.ClientID %>').autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "WebService.asmx/GetAutoCompleteData",
data: "{'kwrds':'" + $("#txtSearch").val() + "'}",
dataType: "json",
success: function (data) {
response(data.d);
alert("message: " + data.toString());
},
error: function (result) {
alert(result);
}
});
}
});
}
Overall, I understand the code, but there are some certain aspects that I'm completely lost in. In the following code "function (request, response) " I understand that it created a function with two parameters, request and response. The request goes to the code behind "WebService" then the response triggers when the"asmx file" send a reply.
What I don't get here is that part "function (data) {
response(data.d)"
what is the (data.d) and why does it use the response as a function? I'm confused I don't get that part at all, and maybe I misunderstand the part I explained. Can someone help me please? I'm so lost here!