채팅 페이지를 만들고 Ajax를 통해 비동기적으로 데이터를 요청할 때, 데이터 반환 여부에 관계없이 iOS는 깜박이지만 Android는 깜박이지 않습니다. 무슨 일이 일어나고 어떻게 해결합니까?
<code>$(document).ready(function(){ $('.loading_box').attr('style','display:none'); ajaxform(); window.setInterval("ajaxform()",3000); }); function ajaxform(){ var id=$(".main_box ul li:last-child").find('.delete_btn').attr('field');//alert(id); $.post( "{:U('App/Friends/ajaxform')}", {"openid":openid,"id":id}, function(data){ if (data) { var str = "";console.log(data); $.each(data, function(index, array) { if(array['openid']==openid){ if(array['type']==0){ //普通文字或图片 str='<li class="chart-right"><div class="chart_text_box"><div class="jieshao"><p>'+array['uname']+'</p><p>'+array['time']+'</p></div><div class="chart_text_qipao_right"><p>'+array['content']+'</p></div><div class="operation_box"><div class="delete_btn" field="'+array['id']+'">删除</div></div></div><div class="persion_img_right"><img src="'+array['headimgurl']+'"><font><img src="{$tpl}App/Friends/Public/img/vipv'+array['classid']+'l.png"></font></div></li>'; }else{ //我的霸屏 str='<li class="chart-right"><div class="chart_text_box"><div class="jieshao"><p>'+array['uname']+'</p><p>'+array['time']+'</p></div><div class="chart_text_qipao_right"><p><i class="money_text">重金霸屏'+arr[array['type']]+'秒</i>'+array['content']; if(array['img']!=""){ str+='<font class="chart_img"><img src="'+array['img']+'"></font>'; } str+='</p></div><div class="operation_box"><div class="delete_btn" field="'+array['id']+'">删除</div></div></div> <div class="persion_img_right"><img src="'+array['headimgurl']+'"><font><img src="{$tpl}App/Friends/Public/img/vipv'+array['classid']+'l.png"></font></div> </li>'; } }else{ if(array['type']==0){ //普通文字或图片 str = ' <li class="chart-left"><div class="persion_img_left"><img src="'+array['headimgurl']+'"><font><img src="{$tpl}App/Friends/Public/img/vipv'+array['classid']+'l.png"></font></div> <div class="chart_text_box"><div class="jieshao"><p>'+array['uname']+'</p><p>'+array['time']+'</p></div><div class="chart_text_qipao_left"><span class="sanjiao_left"></span><p>'+array["content"]+'</p></div>'; if(isadmin){ str+='<div class="operation_box"><div class="delete_btn" field="'+array['id']+'">删除</div> <div class="blacklist" field="'+array['openid']+'">拉黑</div></div>'; } str+='</div> </li>'; }else{ //他人霸屏 str='<li class="chart-left "><div class="persion_img_left"><img src="'+array['headimgurl']+'"><font><img src="{$tpl}App/Friends/Public/img/vipv'+array['classid']+'l.png"></font></div> <div class="chart_text_box"><div class="jieshao"><p>'+array['uname']+'</p><p>'+array['time']+'</p></div><div class="chart_text_qipao_left"><span class="sanjiao_left"></span><p><i class="money_text">重金霸屏'+arr[array['type']]+'秒</i>'+array['content']; if(array['img']!=""){ str+='<font class="chart_img"><img src="'+array['img']+'"></font>'; } str+='</p></div>'; if(isadmin){ str+='<div class="operation_box"><div class="delete_btn" field="'+array['id']+'">删除</div> <div class="blacklist" field="'+array['openid']+'">拉黑</div></div>'; } str+='</div> </li>'; } } $(".main_box ul").append(str); $('.main_box').scrollTop( $('.main_box')[0].scrollHeight ); }); } } ); }</code>
채팅 페이지를 만들고 Ajax를 통해 비동기적으로 데이터를 요청할 때, 데이터 반환 여부에 관계없이 iOS는 깜박이지만 Android는 깜박이지 않습니다. 무슨 일이 일어나고 어떻게 해결합니까?
<code>$(document).ready(function(){ $('.loading_box').attr('style','display:none'); ajaxform(); window.setInterval("ajaxform()",3000); }); function ajaxform(){ var id=$(".main_box ul li:last-child").find('.delete_btn').attr('field');//alert(id); $.post( "{:U('App/Friends/ajaxform')}", {"openid":openid,"id":id}, function(data){ if (data) { var str = "";console.log(data); $.each(data, function(index, array) { if(array['openid']==openid){ if(array['type']==0){ //普通文字或图片 str='<li class="chart-right"><div class="chart_text_box"><div class="jieshao"><p>'+array['uname']+'</p><p>'+array['time']+'</p></div><div class="chart_text_qipao_right"><p>'+array['content']+'</p></div><div class="operation_box"><div class="delete_btn" field="'+array['id']+'">删除</div></div></div><div class="persion_img_right"><img src="'+array['headimgurl']+'"><font><img src="{$tpl}App/Friends/Public/img/vipv'+array['classid']+'l.png"></font></div></li>'; }else{ //我的霸屏 str='<li class="chart-right"><div class="chart_text_box"><div class="jieshao"><p>'+array['uname']+'</p><p>'+array['time']+'</p></div><div class="chart_text_qipao_right"><p><i class="money_text">重金霸屏'+arr[array['type']]+'秒</i>'+array['content']; if(array['img']!=""){ str+='<font class="chart_img"><img src="'+array['img']+'"></font>'; } str+='</p></div><div class="operation_box"><div class="delete_btn" field="'+array['id']+'">删除</div></div></div> <div class="persion_img_right"><img src="'+array['headimgurl']+'"><font><img src="{$tpl}App/Friends/Public/img/vipv'+array['classid']+'l.png"></font></div> </li>'; } }else{ if(array['type']==0){ //普通文字或图片 str = ' <li class="chart-left"><div class="persion_img_left"><img src="'+array['headimgurl']+'"><font><img src="{$tpl}App/Friends/Public/img/vipv'+array['classid']+'l.png"></font></div> <div class="chart_text_box"><div class="jieshao"><p>'+array['uname']+'</p><p>'+array['time']+'</p></div><div class="chart_text_qipao_left"><span class="sanjiao_left"></span><p>'+array["content"]+'</p></div>'; if(isadmin){ str+='<div class="operation_box"><div class="delete_btn" field="'+array['id']+'">删除</div> <div class="blacklist" field="'+array['openid']+'">拉黑</div></div>'; } str+='</div> </li>'; }else{ //他人霸屏 str='<li class="chart-left "><div class="persion_img_left"><img src="'+array['headimgurl']+'"><font><img src="{$tpl}App/Friends/Public/img/vipv'+array['classid']+'l.png"></font></div> <div class="chart_text_box"><div class="jieshao"><p>'+array['uname']+'</p><p>'+array['time']+'</p></div><div class="chart_text_qipao_left"><span class="sanjiao_left"></span><p><i class="money_text">重金霸屏'+arr[array['type']]+'秒</i>'+array['content']; if(array['img']!=""){ str+='<font class="chart_img"><img src="'+array['img']+'"></font>'; } str+='</p></div>'; if(isadmin){ str+='<div class="operation_box"><div class="delete_btn" field="'+array['id']+'">删除</div> <div class="blacklist" field="'+array['openid']+'">拉黑</div></div>'; } str+='</div> </li>'; } } $(".main_box ul").append(str); $('.main_box').scrollTop( $('.main_box')[0].scrollHeight ); }); } } ); }</code>
깜빡이는 것은 페이지가 새로 고쳐졌다는 뜻입니다. 페이지를 다시 렌더링하는 코드가 있는지 확인하세요.