产品要写一个类似检测的东西有四块内容检测,要发四个AJAX。我想到的$,when但是用这个的话,后面三个done时间是立马执行的。我就写了一个settimeout但是里面有一个依次打对号的我就写了一个setInterval但是这个时间老是对不上。发现写法很有问题有没有什么好点的写法或者指出我的错误。$('.txturlbutton').click(function(){varcount=0$.when($.ajax({type:"get",url:"http://www.webossgoo3.com/google/CheckContent",async:true,success:function(data){varpardata=JSON.parse(data)$('.gdt').addClass('layui-animlayui-anim-rotatelayui-anim-loop');$('.coun-jc').hide();$('.txt-betli').removeClass('active')$('.txtnumsectionspan.load-jc').css('display','table-cell');if(pardata.title){$('.cont2i').html('ဆ')$('.cont2i').css('color','red')for(jinpardata.title){$('.contentulul').eq(0).append("
)}};for(kinpardata.keywords){$('.contentulul').eq(1).append("
)}if(!pardata.original){$('.cont1i').html('ဆ');$('.cont1i').css('color','red')}vari=0;setInterval(function(){if(i<=$('.basetxttablei').size()-1){$('.basetxttablei').eq(i).show()i++}else{$('.txt-betli').eq(0).addClass('active')returnfalse}},500)},error:function(){layer.msg('检测失败1')}})).done(function(){setTimeout(function(){$.ajax({type:"get",url:"http://www.webossgoo3.com/google/checkSearch",async:true,success:function(data){varpardata=JSON.parse(data)if(pardata.google){$('.cont3i').html('ဆ')$('.cont3i').css('color','red')}if(pardata.bing){$('.cont4i').html('ဆ')$('.cont4i').css('color','red')}if(pardata.yahoo){$('.cont5i').html('ဆ')$('.cont5i').css('color','red')}if(pardata.title_top1){$('.cont6i').html('ဆ')$('.cont7i').css('color','red')}vara=0;setInterval(function(){if(a<=$('.seartxttablei').length-1){$('.seartxttablei').eq(a).show()a++}else{$('.txt-betli').eq(1).addClass('active')returnfalse}},500)},error:function(){layer.msg('检测失败2')}})})}).done(function(){setTimeout(function(){$.ajax({type:"get",url:"http://www.webossgoo3.com/google/CheckSearch",async:true,success:function(data){varpardata=JSON.parse(data)vari=0;setInterval(function(){if(i<=$('.seotxttablei').length-1){$('.seotxttablei').eq(i).show()i++}else{$('.txt-betli').eq(2).addClass('active')returnfalse}},500)},error:function(){layer.msg('检测失败3')}})},500*($('.seartxttablei').length))}).done(function(){setTimeout(function(){$.ajax({type:"get",url:"http://www.webossgoo3.com/google/CheckContent",async:true,success:function(data){varpardata=JSON.parse(data)vari=0;setInterval(function(){if(i<=$('.basetxttablei').length-1){$('.opttxttablei').eq(i).show()i++}else{$('.txt-betli').eq(3).addClass('active')$('.gdt').removeClass('layui-animlayui-anim-rotatelayui-anim-loop');$('.coun-jc').show()$('.coun-jc').text('88')$('.txtnumsectionspan.load-jc').css('display','none');returnfalse}},500)},error:function(){layer.msg('检测失败4')}})},500*($('.seotxttablei').length)+500*($('.seartxttablei').length))})})
相关分类