[已解决问题]
解决于 2008-03-04 21:33
小弟最近刚开始学习使用json,今天碰到一个问题解决不了,请教一下这里的达人.<br><br>我在后台从数据库里得到一个表格,转化成了json,代码如下:<br><br>string prefix = Web.QueryString<string>("q");<br> DataTable dt = new Query(SubSonic.Generated.Phone.Schema).WHERE("pinyin", Comparison.Like, prefix + "%").ExecuteDataSet().Tables[0];<br> dt.TableName="myword";<br> <br> string a = DataTable2Json(dt);<br> Response.Write(a);<br>============================<br>这里得到的结果是这样子的:<br>{"myword":[{"id":"5","name":"运动鞋","pinyin":"YDX","Num":"dfasd","Dep":"dfasd","remarks":""}]}<br>===================<br>在客户端的代码里我是用jquery处理的:<br>$.get("Test.aspx",{q:"Y"},function(data){<br>alter(data[0].id)<br>})<br>====================<br>这里老是跳不出我想要的结果来,在firefox里调试提示是:<br><div class="errorTitle">alter is not defined</div><div class="objectBox objectBox-stackFrame"><a class="objectLink">(no name)</a>(<span class="objectBox objectBox-string">"{"myword":[{"id":"5","name":"运动鞋","pinyin":"YDX","Num":"dfasd","Dep":"dfasd","remarks":""}]}\r\n\r\n<!DO..."</span><span class="arrayComma"></span>)<span class="objectLink-sourceLink objectLink">custom.js (line 17)</span></div><div class="objectBox objectBox-stackFrame"><a class="objectLink">success</a>()</div>==========<br>不知道是在哪里出了问题,高手请指点一下,我的目的是想从服务器端返回json供客户端的jquery的autocomplete使用,因为asp.net ajax controlltoolkit里的那个autocomplete的功能实在是太有限了 ....<br><br><br><br>
帝之晓
|
初学一级
|
园豆:
98
提问于:2008-03-04 00:03