I want to return the “No Record Found” message as ListItem when there is no record. I managed to detect whether the result is empty or not by using “data.d”. However, I don’t know how to return “No Record Found” as the data item. Could you please help me with this? Thanks.
$.ajax({
url: "/WebServices/Misc.asmx/GetOtherQualifications",
data: "{ 'ModuleID': '" + $("#<%= hdModuleRef.ClientID %>").val() + "', 'search': '" + $("#<%= txtCourseName.ClientID %>").val() + "' }",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (data) {
if (data.d == "") {
return {
value: "No record found",
id: -1
}
}
else {
response($.map(data.d, function (item) {
return {
value: item.Name,
id: item.KeyID
}
}))
}
}
Instead of:
You need to call the
responsefunction, which notifies the widget of results: