request.term = request.term.replace("'", "\\'");
Here is the complete function with the new line of code added in the appropriate location:
$("#<%=txtSelectUserName.ClientID %>").autocomplete({
source: function (request, response) {
request.term = request.term.replace("'", "\\'");
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "/ADGroupManagementWS.asmx/GetAllADUsers",
data: "{'keywordStartsWith':'" + request.term + "'}",
dataType: "json",
async: true,
success: function (data) {
response(data.d);
},
error: function (result) {
alert("Due to unexpected errors, data could not be loaded");
}
});
},
minLength: 1
});