开发者

newbie: dummy JSON source?

Im using a jquery ui's autocomplete, which require a "source". I want to get it to work with a remote datasource. So i tried creating test.html and added a json string

[
        {
            value: "1",
            label: "Hot'N'Sweet",
            desc: "124.00 SEK",
            icon: "ajax_productdummy_1.png",
            likes: "12"
        },
        {
            value: "2",
            label: "Tuborg Julöl",
            desc: "229.00 SEK",
     开发者_如何学编程       icon: "ajax_productdummy_2.png",
            likes: "2"
        },
        {
            value: "3",
            label: "Famous Grouse",
            desc: "449.00 SEK",
            icon: "ajax_productdummy_3.png",
            likes: "54"
        }
    ]

But when i specify "test.html" as source, nothing happens. Later on i will have an .ashx file returning a json string. But for now i want this dummy source. What did i miss?


I think the JSON is invalid, When you run it through the validator at http://jsonformatter.curiousconcept.com/ it says the strings need double quotes (here, it's the variable names that are missing them). I think it should look like this:

[
   {
      "value":"1",
      "label":"Hot'N'Sweet",
      "desc":"124.00 SEK",
      "icon":"ajax_productdummy_1.png",
      "likes":"12"
   },
   {
      "value":"2",
      "label":"Tuborg Julöl",
      "desc":"229.00 SEK",
      "icon":"ajax_productdummy_2.png",
      "likes":"2"
   },
   {
      "value":"3",
      "label":"Famous Grouse",
      "desc":"449.00 SEK",
      "icon":"ajax_productdummy_3.png",
      "likes":"54"
   }
]

Hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜