


javascript - ajax asynchronously requests data, ios screen flashes
When making a chat page, when ajax requests data asynchronously, regardless of whether there is data returned, ios will flash, but android will not flash. What is going on and how to solve it
<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>
Reply content:
When making a chat page, when ajax requests data asynchronously, regardless of whether there is data returned, ios will flash, but android will not flash. What is going on and how to solve it
<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>
Flashing means the page has been refreshed, check if there is code to re-render the page.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

In this chapter, we are going to learn the following topics related to routing ?

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

Validator can be created by adding the following two lines in the controller.
