2
我正在使用此jQuery autocomplete plugin。從jQuery自動完成返回格式化json對象
我希望我的返回數據是json格式。
searchPopup:function(){
$("input.searchField").autocomplete("myjson1.json", {
dataType: 'json',
parse: function(data) {
$.each(data.productList, function(k, v) {
jQuery(".searchPanel").append("<div class="+k+"><h2>"+k+"</h2><ul class="+k+"></ul</div>");
$.each(v, function(k1, v1) {
$.each(v1, function(k2, v2) {
jQuery("ul."+k).append("<li>"+v2+"</li>");
});
});
});
},
max: 50
});
}
當我分析這個數據,它給了一個錯誤
c.split是不是一個函數
如何這個問題能解決?
{
"productList" : {
"Byproducts" : [
{
"brand":"Bosch",
"productname":"Jigsaw blade",
"price":50
},
{
"brand":"Bosch1",
"productname":"Jigsaw blade",
"price":51
},
{
"brand":"Bosch2",
"productname":"Jigsaw blade",
"price":52
},
{
"brand":"Bosch3",
"productname":"Jigsaw blade",
"price":53
}
],
"Spareparts" : [
{
"brand":"BoschS1",
"productname":"Jigsaw blade",
"price":50
}
],
"Bybrand" : [
{
"brand":"BoschBY"
}
],
"Bycategory" : [{
"brand":"BoschBYc",
"productname":"Jigsaw blade",
"price":50
} ]
}
}
如此溫柔,重新格式化您的代碼,請。這樣沒有人會真正閱讀它;) – 2010-12-07 15:49:18
+1 to @faileN,這個問題是不可讀的,請在發佈前修正格式。謝謝 – marcgg 2010-12-07 15:52:14