오늘 웹 사이트에서 jQuery의 버전을 1.4에서 1.5.1로 변경했지만 getJson
함수가 작동을 멈추는 함수가있었습니다 , 나는 API를 보았고 요청은 getRequest이므로 이전 버전과의 호환성이 있다고 가정했다.JQuery 1.4에서 1.5.1로 변경되었고 getJson이 작동을 멈췄습니다.
function EmailAutoComplete(firstName, lastName, target) {
// Query /AutoComplete/Email?FirstName=&LastName= for an e-mail
// list and populate the select box target with the results.
$.getJSON('@Url.Action("AutoComplete", "Email")', {
FirstName: firstName,
LastName: lastName
}, function(matchingEmails) {
var oldVal = target.val();
target.empty();
if (matchingEmails == null || matchingEmails.length == 0) {
target.append('<option value="">E-mail address not found</option>');
} else {
$.each(matchingEmails, function(key, val) {
var selected = (val == oldVal) ? 'selected="selected"' : '';
target.append('<option value="' + val + '" ' + selected + '>' + val + '</option>');
});
if (matchingEmails.length > 1) {
target.addClass("multipleEmailsAvailable");
} else {
target.removeClass("multipleEmailsAvailable");
}
}
});
}
다른 사람이 같은 문제가 있었 : 여기
코드인가?감사합니다. 알렉스.
시도해 보시라.하지만 Json을 얻으려면 getJson을 사용하지 않는 이유는 무엇입니까? –
http://api.jquery.com/jQuery.getJSON/ – Hussein
읽어 주셔서 감사합니다. –