工作這是我的Jquery:jQuery UI的自動完成不asp.net
$("#completeMe").autocomplete({
source: function (request, response) {
$.ajax({
url: "/Main.aspx/GetAutocomplete",
type: "POST",
dataType: "json",
data: Data,
contentType: "application/json; charset=utf-8",
success: function (data) {
response($.map(data, function (item) {
return { value: item };
}))
}
})
}
});
這是我Main.aspx.cs:
[System.Web.Services.WebMethod]
public static List<string> GetAutocomplete(string cityName)
{
List<string> City = new List<string>() { "hh", "hh1" };
return City;
}
現在這個工程時,我不是返回列表的字符串。但是,當我使用它像這樣用列表我得到:
Uncaught TypeError: undefined is not a function jquery-ui.min.js:9...
我不明白,這個方案似乎工作的許多人在網上,也許有事情做與我的jquery/UI版本?我正在使用jquery 1.7.1.min和jquery-ui最新版本。
可能值得一看你從WebMethod得到的迴應;在瀏覽器中使用開發人員控制檯,通常通過按F12鍵激活。 –