Javascript 如何制作一个从单独的txt文件中获取文章的web博客?

Javascript 如何制作一个从单独的txt文件中获取文章的web博客?,javascript,php,html,css,Javascript,Php,Html,Css,我想在我自己的网站上写博客,而不使用Wordpress、Joomla等服务,这些服务从单独目录中的文本文件中获取内容,并将其显示在网页上。这就是我到目前为止所做的: HTML doggo.info $('#load').load(“posts/post0.txt”); $('#posttitle').html($('#load').find('#title').html()); $('postdate').html($('load').find('date').html()); $('

我想在我自己的网站上写博客,而不使用Wordpress、Joomla等服务,这些服务从单独目录中的文本文件中获取内容,并将其显示在网页上。这就是我到目前为止所做的:

HTML

doggo.info

$('#load').load(“posts/post0.txt”); $('#posttitle').html($('#load').find('#title').html()); $('postdate').html($('load').find('date').html()); $('postcontent').html($('load').find('content').html());
0.TXT
职位名称
1/1/1990
嗨,我是博客。

确实如此
什么是生活?
如果有更好的方法格式化我的txt文件,我愿意更改它们

我希望能够在posts文件夹中有多个文件,并让站点以分散顺序(99.txt、98.txt、97.txt…0.txt)将它们加载到textbox divs内的页面中。我还想把它分成10页左右的文章一页


我几乎被难倒了,所以任何帮助都将不胜感激。您可以查看到目前为止我得到的信息。

使用JSON和AJAX访问您想要显示的信息

JavaScriptObjectNotation或JSON是一种格式化文件和访问所需信息的方法

[

]

该文件保存为“.json”,其内容组织为对象

如果您是JSON新手,本视频非常有用


是,请切换到
.json
.xml
。这些很容易解析。
<html>
<head>
    <title>doggo.info</title>

    <link rel='shortcut icon' href='favicon.ico' type='image/x-icon' />
    <meta http-equiv="content-type" content="text/html; charset=utf-8" >
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="stylesheet" type="text/css" href="http://doggo.info/stylesheet.css">
    <style type="text/css">
    </style>

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script src="http://doggo.info/navbar.js"></script>
</head>

<body>
<header>
  <img src="/images/navicon.png" onclick="openNav()" width="40" height="48" alt="Open Menu">
  <a href="/" title="Home Page"><em>doggo.info</em></a>
</header>
<div id="sidenav">
  <a id="current">curlink</a>
  <a href="">otherlink</a>
</div>

<div id="load" style="display:none;"></div>
<div class="content">
  <div class="container text-center">
    <div class="textbox">
      <p id="posttitle"></p>
      <p id="postdate"></p>
      <p id="postcontent"></p>
    </div>
  </div>
</div>

<footer>
  <p class="footer"><a href="/">doggo.info</a></p>
</footer>
</body>

<script>
$('#load').load("posts/post0.txt");
$('#posttitle').html($('#load').find('#title').html());
$('#postdate').html($('#load').find('#date').html());
$('#postcontent').html($('#load').find('#content').html());
</script>

</html>
<div id="title">Title of post</div>
<div id="date">1/1/1990</div>
<div id="content">
hi, i am blog.
<br>
<em>indeed</em>, it is true
<br>
what is <strong>life</strong>?
</div>
  {

  "Title": "Title of post",

  "Date" : "1/1/1990",

  "Content": "h, i am blog"
  }