[英]Javascript templating values coming from JSON
I am trying to create a Javascript template with tables and I want to replace the values with JSON data. 我正在尝试使用表创建一个Javascript模板,我想用JSON数据替换值。 But I am having a hard time replacing the template data with JSON.
但我很难用JSON替换模板数据。 maybe I am confusing you but http://jsfiddle.net/k6pJz/ is where I am.
也许我很困惑你,但http://jsfiddle.net/k6pJz/就在我身边。 All your help is highly appreciated.
非常感谢您的所有帮助。
Fixed: http://jsfiddle.net/k6pJz/10/ 修正: http : //jsfiddle.net/k6pJz/10/
This code had multiple syntax errors, and malformed JSON. 此代码有多个语法错误和格式错误的JSON。 And would still not have worked afte that.
并且仍然没有在那里工作。 To name a few:
仅举几例:
foo.innerHTML; .replace('a', 'b')
/
character. /
字符开头。 .data
element. .data
元素。 Lastly, you may want to look into some templating libraries like the one built into jQuery or Mustache . 最后,您可能想要查看一些模板库,例如jQuery或Mustache中 内置的库。 Thats only two but there are tons, and they make your life much easier.
这只有两个,但有吨,它们让你的生活更轻松。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.