jquery ajax嵌套循环,将数据显示到页面,但是循环次数对,每次都显示同一条数据, 代码: 50
$.ajax({async:false,url:root+"/recordcode/recordcode/domainList",success:function(dat...
$.ajax({
async : false,
url:root+"/recordcode/recordcode/domainList",
success:function(data) {
var json=eval("("+data+")");//转化为json格式。
for(i =0;i<json.length;i++){
//var jsonobj = json[i];
var domainid=json[i].domainid;
var domainname=json[i].domainname;
var recordcode=json[i].recordcode;
var username=json[i].username;
//alert(domainid+" "+domainname+" "+recordcode+" "+username);
var temp="true";
$.ajax({
url:root+"/recordcode/recordcode/checkRecordCode",
data:{'domainid':domainid,'domainname':domainname,'recordcode':recordcode,'username':username},
cache:false,
success:function(data) {
if(data=="false") {
temp=data;
}
if(data!="false" && data!="same"){
_addTd="<tr id='tr"+domainid+"' class=\"out\" onmouseover=\"this.className='over'\" onmouseout=\"this.className='out'\"><td>"
+username+"</td><td>"
+domainname+"</td><td>"
+recordcode+"</td><td>"
+data+"</td><td>"
+" "+"</td><td></td>"
+"</tr>"
$(".tab_title").after(_addTd);
}
}
})结果如图,谁能帮忙解决下,分数不是问题 展开
async : false,
url:root+"/recordcode/recordcode/domainList",
success:function(data) {
var json=eval("("+data+")");//转化为json格式。
for(i =0;i<json.length;i++){
//var jsonobj = json[i];
var domainid=json[i].domainid;
var domainname=json[i].domainname;
var recordcode=json[i].recordcode;
var username=json[i].username;
//alert(domainid+" "+domainname+" "+recordcode+" "+username);
var temp="true";
$.ajax({
url:root+"/recordcode/recordcode/checkRecordCode",
data:{'domainid':domainid,'domainname':domainname,'recordcode':recordcode,'username':username},
cache:false,
success:function(data) {
if(data=="false") {
temp=data;
}
if(data!="false" && data!="same"){
_addTd="<tr id='tr"+domainid+"' class=\"out\" onmouseover=\"this.className='over'\" onmouseout=\"this.className='out'\"><td>"
+username+"</td><td>"
+domainname+"</td><td>"
+recordcode+"</td><td>"
+data+"</td><td>"
+" "+"</td><td></td>"
+"</tr>"
$(".tab_title").after(_addTd);
}
}
})结果如图,谁能帮忙解决下,分数不是问题 展开
展开全部
怎么说呢,ajax不支持嵌套,试试分开,比如这样:
$.ajax({
async : false,
url:root+"/recordcode/recordcode/domainList",
success:function(data) {
var json=eval("("+data+")");//转化为json格式。
for(i =0;i<json.length;i++){
//var jsonobj = json[i];
var domainid=json[i].domainid;
var domainname=json[i].domainname;
var recordcode=json[i].recordcode;
var username=json[i].username;
//alert(domainid+" "+domainname+" "+recordcode+" "+username);
var temp="true";
tichulai(domainid,domainname,recordcode,username,temp);
}
}
});
function tichulai(domainid,domainname,recordcode,username,temp){
$.ajax({
url:root+"/recordcode/recordcode/checkRecordCode",
data:{'domainid':domainid,'domainname':domainname,'recordcode':recordcode,'username':username},
cache:false,
success:function(data) {
if(data=="false") {
temp=data;
}
if(data!="false" && data!="same"){
_addTd="<tr id='tr"+domainid+"' class=\"out\" onmouseover=\"this.className='over'\" onmouseout=\"this.className='out'\"><td>"
+username+"</td><td>"
+domainname+"</td><td>"
+recordcode+"</td><td>"
+data+"</td><td>"
+" "+"</td><td></td>"
+"</tr>"
$(".tab_title").after(_addTd);
}
}
});
}
$.ajax({
async : false,
url:root+"/recordcode/recordcode/domainList",
success:function(data) {
var json=eval("("+data+")");//转化为json格式。
for(i =0;i<json.length;i++){
//var jsonobj = json[i];
var domainid=json[i].domainid;
var domainname=json[i].domainname;
var recordcode=json[i].recordcode;
var username=json[i].username;
//alert(domainid+" "+domainname+" "+recordcode+" "+username);
var temp="true";
tichulai(domainid,domainname,recordcode,username,temp);
}
}
});
function tichulai(domainid,domainname,recordcode,username,temp){
$.ajax({
url:root+"/recordcode/recordcode/checkRecordCode",
data:{'domainid':domainid,'domainname':domainname,'recordcode':recordcode,'username':username},
cache:false,
success:function(data) {
if(data=="false") {
temp=data;
}
if(data!="false" && data!="same"){
_addTd="<tr id='tr"+domainid+"' class=\"out\" onmouseover=\"this.className='over'\" onmouseout=\"this.className='out'\"><td>"
+username+"</td><td>"
+domainname+"</td><td>"
+recordcode+"</td><td>"
+data+"</td><td>"
+" "+"</td><td></td>"
+"</tr>"
$(".tab_title").after(_addTd);
}
}
});
}
追问
…………你out了,支持的,这个我早都解决了,好久了这个问题,一直没人回答所以没法采纳,终于回答了,还是个错的…………纠结,百度怎么把那个无满意答案关闭问题给取消了呢……
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询