我有一個文本框, 裏面我希望它自動完成。 自動完成的數據將通過數據庫給出。自動完成jquery不工作?
這是我的Jquery:
var data = "autocompletetagdata.aspx"
$("#item").autocomplete({
source: data
});
這是我已經把autocompletetagdata現在:
protected void Page_Load(object sender, EventArgs e)
{
string term = Request.QueryString["term"];
SqlConnection myConnection = new SqlConnection(connStr);
myConnection.Open();
string SQL = ("select Top 10 LTRIM(RTRIM(PGPRDC)) As PGPRDC FROM SROPRG SROPRG");
SqlCommand myCommand = new SqlCommand(SQL, myConnection);
StringBuilder sb = new StringBuilder();
try
{
SqlDataReader reader = myCommand.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
sb.Append(reader.GetString(0))
.Append(Environment.NewLine);
}
}
reader.Close();
}
catch (Exception ex)
{
myConnection.Close();
}
myConnection.Close();
Response.Write(sb.ToString());
//return "['word', 'hello', 'work', 'oi', 'hey']";
}
我到底做錯了什麼?
編輯:
<script type="text/javascript" src="/scripts/js/jquery.scrollTo-min.js"></script>
<script type="text/javascript" src="/scripts/js/jquery.flash.min.js"></script>
<script type="text/javascript" src="/scripts/js/jquery.sifr.min.js"></script>
<script type="text/javascript" src="/scripts/js/global.js"></script>
<script type="text/javascript" src="/scripts/js/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="/scripts/js/orderstatus.js"></script>
<script type="text/javascript" src="/scripts/js/jquery.ui.core.js"></script>
<script type="text/javascript" src="/scripts/js/jquery.ui.widget.js"></script>
<script type="text/javascript" src="/scripts/js/jquery.ui.datepicker.js"></script>
<script type="text/javascript" src="/scripts/js/jquery.qtip-1.0.0-rc3.min.js"></script>
<script type="text/javascript" src="/scripts/js/json_parse.js"></script>
當你走在你回來的屏幕上的瀏覽器autocompletetagdata..aspx ...
SC052 SC053 SC055 SC060 SC061 SC062 SC063 SG011 SG014 SG015
螢火蟲也確實顯示出被送回在這些項目的反應,但沒有任何反應的文本框
autocompletetagdata.aspx應返回JSON編碼數據,例如'['SC052','SC053']'等等。這就是jQuery-ui自動完成所期望的。 – 2012-01-16 11:07:48