HTML code:
<div id= "News" ></div>
Txt:
[
{"id": "1", "News": "Notice: Facing Enterprise Social Security pain Point--why enterprise social insurance outsourcing trend", "url": "Http://www.baidu.com"},
{"id": "2", "News": "A good hr is like a good CEO", "url": "https://www.taobao.com/"},
{"id": "3", "News": "Content operations do not do well, and text editing no difference", "url": "https://www.taobao.com/"},
{"id": "4", "News": "The root of the product survival: Core function", "url": "https://www.taobao.com/"},
{"id": "5", "News": "What are the pitfalls of patent Application", "url": "https://www.taobao.com/"},
{"id": "6", "News": "Management software SaaS enterprise application, dial" cloud "See Day", "url": "https://www.taobao.com/"},
{"id": "7", "News": "Dream Capital", "url": "https://www.taobao.com/"}
]
Js:
<script type= "Text/javascript" >
$.ajax ({
Type: "POST",
ContentType: "Application/x-www-form-urlencoded;charset=utf-8",
URL: "Newsinfo.txt",
DataType: "JSON",
Success:function (data) {
var info= "<ul>";
I represents the index position in data, and N represents the object containing the information
$.each (Data,function (i,n) {
var str= "<li><a href= '" +n["url"]+ ">" +n["News"]+ "</a></li>";
INFO+=STR;
});
info+= "</ul>";
$ (' #news '). Append (info);
}
});
</script>
Using AJAX to read data from TXT