0
여기에 뭔가 빠져 있어야하지만 jQuery UI의 자동 완성 기능을 ASP.NET 페이지 메소드와 함께 사용하려고합니다. 나는 확실히 작동하는 방법의 반응을 직렬화 JSON.NET를 사용하여,이 반환하고 있습니다 :jQuery Autocomplete JSON with JSON
$("#txtName").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
url: "MyPage.aspx/GetPerson",
data: "{ 'q': '" + request.term + "', 'limit': '10' }",
contentType: "application/json",
dataFilter: function (data) { return data; },
success: function (data) {
var result = $.parseJSON(data.d)
response($.map(result, function (item) {
return {
label: item.ADMIN_NAME,
value: item.ADMIN_ID
}
}))
},
error: function (xhr, status, errorThrown) {
alert("Error: " + xhr.responseText);
}
});
},
minLength: 1
});
문제는 여기
[{"ADMIN_ID":1,"ADMIN_NAME":"SMITH"}]
을 ... 그리고 나의 jQuery 코드입니다 자동 완성에 항목이 표시되지 않습니다. 어떤 아이디어?
$('#txtName').result(function(event, data, formatted) {
$("#result").html(!data ? "No match!" : "Selected: " + formatted);
});
내가 다시 내 페이지 방법에서 왔을 때 나는 JSON을 구문 분석하지 않았다 바보 : –