var express=require("express");
var app=express();
var data=[{
"aaa":"bbb"
}]
app.use(express.static("./public"));
app.get("/news",function(req,res){
res.json(data);
});
app.listen(3000);
// app.js
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body>
<h1 class="h1">我的第一个标题</h1>
</body>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
<script type="text/javascript">
$.get("/news",function(data,status){
console.log(data);
$(".h1").html(data[0].aaa);
})
</script>
</html>
用ajax获取