[英]Append JSON object in index.html
I have a json object in my service file and I want to retrieve that object in index.html file and then append it into script tag. 我的服务文件中有一个json对象,我想在index.html文件中检索该对象,然后将其附加到脚本标记中。
In my service file I've try like this: 在我的服务文件中,我尝试这样:
document.getElementById('b24meta').nodeValue = JSON.stringify(b4authData);
Using the nodeValue
can be troublesome unless you really know how to use it. 除非你真的知道如何使用它,否则使用nodeValue
会很麻烦。 You will have to locate a text node if you want to display text inside a DOM element this way. 如果要以这种方式在DOM元素内显示文本,则必须找到文本节点。 Much simpler methods are available and are easy to use. 有许多更简单的方法,并且易于使用。
document.getElementById('b24meta').innerHTML= JSON.stringify(b4authData);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.