JSON模板不显示

时间:2013-03-13 19:26:18

标签: javascript json

我正在尝试使用JS创建JSON模板 这是我的代码。由于某种原因,它没有显示任何结果。可以请一些人检查问题是什么

<html>

  <head>

    <script type="text/javascript"src=""http://jsontemplate.googlecode.com/svn/trunk/javascript/json-template.js"">
    </script>
    <script type="text/javascript">
function write() {
      var t = jsontemplate.Template("{# This is a comment and will be removed from the output.}\n\n{.section products}\n  <h2>Products for Dove</h2>\n\n  <table width=\"100%\">\n  {.repeated section products}\n    <tr><td>{Product Name}</td>\n</tr>\n  {.end}\n  </table>\n{.or}\n  <p><em>(No page content matches)</em></p>\n{.end}\n");

var s = t.expand({

        "products": [{
        "Product Name": "dove moisturiser"


    },


    {
        "Product Name": "Deodrant"

    }]
});
document.getElementById("replace").innerHTML = s;

}         </script>       </head>       <body onload="write();">        <h4>This is for test.</h4>        <div id="replace"></div>      </body>    </html>

0 个答案:

没有答案