我刚刚在我的项目中尝试了 fcbkcomplete,但是我在调用 ajax 请求以将结果获取到自动完成时遇到了麻烦,有人知道如何完成吗?
服务器端 :
public static string tagFriendAutocomplete()
{
string Result = "";
string query = "select fr.FRIEND_ID,c.[USER_NAME] from clients c inner join friends fr on c.CLIENT_ID=fr.FRIEND_ID and fr.CLIENT_ID=1 and c.[USER_NAME] like '%a%' ";
DataTable dt = new SQLHelper(SQLHelper.ConnectionStrings.WebSiteConnectionString).getQueryResult(query);
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
Result += dt.Rows[i]["USER_NAME"] + ",";
}
}
return Result;
}
客户端 :
$(document).ready(function () {
$("#select3").fcbkcomplete({
//"autoCompleteFriendTag/data.txt",
addontab: true,
maxitems: 10,
input_min_size: 0,
height: 10,
cache: true,
newel: false,
select_all_text: "select"
});
});
我不知道在哪里放置 jquery ajax 代码任何帮助请我已经 2 天寻找解决方案,但遗憾的是我找不到我的 ajax 代码是:
$.ajax({
type: 'POST',
url: 'Testautocomplete.aspx/tagFriendAutocomplete',
data: "{}",
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (data) {
return data.d.split(',');
},
error: function (xhr) {
alert("responseText: " + xhr.responseText);
}
});