以下代码可以在搜索不包含撇号的任何名称时正常运行。当您尝试查找姓名中包含撇号的人时,它会失败(返回错误)。如何允许找到带有撇号的人?
function autoComplete() {
$(document).ready(function () {
$(".AutoCompleteClass").autocomplete({
source: function (request, response) {
$.ajax({
url: "/Service/NomineeWebService.asmx/GetMatchingActiveDirectoryUsers",
data: "{ 'SearchCharacters': '" + request.term + "' }",
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 {
id: item.NomineeUserName,
value: item.NomineeLastNameFirstName + " - " + item.NomineeDomainAndUserName,
data: item
}
}))
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
}
});
},
delay: 150,
minLength: 3,
select: function (event, ui) {
$('.SelectedUserNameWrapper input[type=hidden]').val(ui.item.id);
}
});
});
$('#AutoCompleteTextBox').keypress(function (event) {
if (event.which == '13') {
alert('test');
$('#AutoCompleteButton').click();
}