首先,生成json文件的方式一定要对。之前我是用txt文件直接改的后缀,读出来乱码,用网上的json工具创建才行
$.ajax
({
url: json_url,//json文件位置
type: "GET",//请求方式为get
dataType: "json", //返回数据格式为json
success: function (data)
{
//请求成功完成后要执行的方法
//each循环 使用$.each方法遍历返回的数据date
$.each
(
data.text, function (i, item)
{
for(var j=0;j<item.tip.length;j++)
{
var wordtemp ="<div>"+item.tip[j]+"</div>";
$("#jsonmark").append(wordtemp);
console.log($("#jsonmark"));
}
}
)
}
})