Jquery解析JSON数据(3)
来源:未知 责任编辑:责任编辑 发表时间:2014-02-18 03:25 点击:次
SqlDataAdapter sda = new SqlDataAdapter(sql, con);
DataTable dt = new DataTable();
sda.Fill(dt);
foreach (DataRow dr in dt.Rows)
{
str.AppendFormat
("{{name:\"{0}\",value:\"{1}\"}},", dr["TeacherName"], dr["TeacherNum"]);
}
Response.Write("[" + str.ToString().TrimEnd(',') + "]");
Response.End();
}
}
②前台解析JSON数据
<head runat="server">
<title></title>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/jquery.autocomplete.js"></script>
<link rel="Stylesheet" href="css/jquery.autocomplete.css" type="text/css" />
<script type="text/javascript">
$(function() {
$.getJSON(
"AutoDB2.aspx", function(data) {
$("#txt").autocomplete(data, {
minChars: 0,
//cacheLength: 1,
//multiple: true,
matchContains: true,
autoFill: false,
mustMatch: true,
//delay: 100,
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>