简体   繁体   English

如何使用javascript动态加载生成的html?

[英]How to dynamically load generated html with javascript?

I am making a website using HTML, CSS and Javascript.我正在使用 HTML、CSS 和 Javascript 制作网站。 What I'm currently trying to do is making a Javascript that simplifies the way to add more 'items' to a website.我目前正在尝试做的是制作一个 Javascript 来简化向网站添加更多“项目”的方式。 For example a store item.例如商店商品。 Please see http://nl.tinypic.com/r/t5khtf/9 .请参阅http://nl.tinypic.com/r/t5khtf/9

Those are 3 items that I am adding in this Javascript.这些是我在此 Javascript 中添加的 3 个项目。 However, it keeps telling me that the items are UNDEFINED...但是,它一直告诉我这些项目是 UNDEFINED ......
Here is the code from the JavaScript http://pastebin.com/hjL9MByY .这是来自 JavaScript http://pastebin.com/hjL9MByY的代码。
Here is how I load it into a div:这是我将它加载到 div 中的方法:

<div id="store_beatles_eps"></div>

How do I fix this?我该如何解决? Any help would be very much appreciated.任何帮助将不胜感激。
If I made any mistakes in the question, please report that to me and I'll change it :).如果我在问题中犯了任何错误,请向我报告,我会更改它:)。

You use wrong variable.您使用了错误的变量。 Instead of this:取而代之的是:

function generateStoreItem(item)
  ... 
  r = r.replace("{{page}}", store_beatles_eps.itemPage);

you should have你应该有

function generateStoreItem(item)
   ... 
   r = r.replace("{{page}}", item.itemPage);

And yet, while ago I did simple repeatable() jQuery plugin for that purpose: https://github.com/c-smile/repeatable然而,不久前我为此做了简单的 repeatable() jQuery 插件: https : //github.com/c-smile/repeatable

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM