我使用AJAX这个JQuery:
<script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script src="../Scripts/jquery.autocomplete.js" type="text/javascript"></script>
<script src="../Scripts/jquery-1.5.1.js" type="text/javascript"></script>
<script type ="text/javascript">
var data = "";
$(document).ready(function () {
$("#tbSearch").change(function () {
$.ajax({
type: "POST",
url: "AgentList.aspx/LoadData",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
data = msg.d.split(" ");
$("#tbSearch").autocomplete("minLength", 0);
$("#tbSearch").autocomplete("search", "");
$("#tbSearch").autocomplete("AgentList.aspx/LoadData");
}
});
});
});
</script>
这是显示自动完成中应该存在的内容的函数:
#region "Auto Complete"
[System.Web.Services.WebMethod]
public static string[] LoadData()
{
string[] arra = new string[] {"Small", "Money", "People", "So", "Some", "Rome", "Test", "John", "Angel", "J", "Damn you"};
return arra;
}
#endregion
我的JQ甚至没有开火。我不知道这里有什么问题:(