function getData()
{
$.ajax({
type:"get",
url:"10.16.61.60:90/solr/core2/select?q=phrase:hard%20drive&wt=json&indent=true&rows=6&start=5 ",
dataType: "json",
data:{zip:Math.random()},
success:function(result){
if(result.status==0){
$.each($(result.response.docs),function(i,n){
var index=n.index;
var phrase=n.phrase;
});
}
}
});
}
比如你接收到的数据为data,
然后就是循环数据var arr=data.response.docs;var _html='';
for(var i=0,len=arr.length;i
var phrase=arr[i]["phrase"];
_html+='
}
然后把_html加入的想要放的dom中。原理大概就这样的。
$.ajax({
url:"10.16.61.60:90/solr/core2/select?q=phrase:hard%20drive&wt=json&indent=true&rows=6&start=5",
dataType:"JSON",
type:"GET",
success:function(res){
//拿到需要用到数据集,
var resList = res.response.docs;
//拼接数据渲染到html
var tpl = "";
resList.forEach(function(item){
tpl+=""+item.index+""+item.phrase+""+""+item._version_+""
$("#id").html(tpl);
);
});
},
error:function(err){
console.log("错误:"+err);
}
});
function getData()
{
$.ajax({
type:"get",
url:"10.16.61.60:90/solr/core2/select?q=phrase:hard%20drive&wt=json&indent=true&rows=6&start=5 ",
dataType: "json",
data:{zip:Math.random()},
success:function(result){
if(result.status==0){
$.each($(result.response.docs),function(i,n){
var index=n.index;
var phrase=n.phrase;
});
}
}
});
}