作者:果粒粒1201 | 来源:互联网 | 2023-06-02 14:02
The title really says it all, but I'd like to have a file with many strings in a folder with my .html file, and somehow load them into the page, perhaps with document.write() or something like that. The website follows one template, and I need to have many string files to interchangeably load into the document, as I imagine a social network does with it's profile page. For example:
标题真的说明了一切,但是我希望在我的.html文件的文件夹中有一个包含许多字符串的文件,并以某种方式将它们加载到页面中,可能使用document.write()或类似的东西。该网站遵循一个模板,我需要有许多字符串文件可互换加载到文档中,因为我想社交网络与它的配置文件页面。例如:
"My name is $NAME. I'm %AGE years old. I'm %HEIGHT inches tall." % ('Files/strings.txt')
with the file laid out like this:
文件的布局如下:
$NAME = 'Bob'
$AGE = '20'
$HEIGHT = '70'
or
Bob
20
70
or even
Bob.20.70
Any way I can do this would be nice, though I don't particularly enjoy AJAX. There is no data transfered from the client, so it seems I shouldn't need AJAX.
我能做到的任何方式都会很好,尽管我并不特别喜欢AJAX。没有从客户端传输的数据,所以我似乎不需要AJAX。
3 个解决方案