Javascript-ajax asynchronous request data, iOS screen flashing

Source: Internet
Author: User
Tags openid
Make a chat page, Ajax asynchronous request data, regardless of whether there is no data return, iOS will flash a bit, and Android will not flash, this is how to solve

$ (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) { Plain text or picture str= '
  • ' +array[' uname ']+ '

    ' +array[' time ']+ '

    ' +array[' content ']+ '

    Delete
  • '; }else{//My PA screen str= '
  • ' +array[' uname ']+ '

    ' +array[' time ']+ '

    A hefty splash screen ' +arr[array[' type ']]+ ' s ' +array[' content '; if (array[' img ']!= "") {str+= '; } str+= '

    Delete
  • '; }}else{if (array[' type ']==0) {//plain text or picture str = '
  • ' +array[' uname ']+ '

    ' +array[' time ']+ '

    ' +array[' content "]+ '

    '; if (isadmin) {str+= ' remove pull black '; } str+= '
  • '; }else{//Others PA screen str= '
  • ' +array[' uname ']+ '

    ' +array[' time ']+ '

    A hefty splash screen ' +arr[array[' type ']]+ ' s ' +array[' content '; if (array[' img ']!= "") {str+= '; } str+= '

    '; if (isadmin) {str+= ' remove pull black '; } str+= '
  • '; }} $ (". Main_box ul"). Append (str); $ ('. Main_box '). ScrollTop ($ ('. Main_box ') [0].scrollheight]; }); } } );}

    Reply content:

    Make a chat page, Ajax asynchronous request data, regardless of whether there is no data return, iOS will flash a bit, and Android will not flash, this is how to solve

    $ (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) { Plain text or picture str= '
  • ' +array[' uname ']+ '

    ' +array[' time ']+ '

    ' +array[' content ']+ '

    Delete
  • '; }else{//My PA screen str= '
  • ' +array[' uname ']+ '

    ' +array[' time ']+ '

    A hefty splash screen ' +arr[array[' type ']]+ ' s ' +array[' content '; if (array[' img ']!= "") {str+= '; } str+= '

    Delete
  • '; }}else{if (array[' type ']==0) {//plain text or picture str = '
  • ' +array[' uname ']+ '

    ' +array[' time ']+ '

    ' +array[' content "]+ '

    '; if (isadmin) {str+= ' remove pull black '; } str+= '
  • '; }else{//Others PA screen str= '
  • ' +array[' uname ']+ '

    ' +array[' time ']+ '

    A hefty splash screen ' +arr[array[' type ']]+ ' s ' +array[' content '; if (array[' img ']!= "") {str+= '; } str+= '

    '; if (isadmin) {str+= ' remove pull black '; } str+= '
  • '; }} $ (". Main_box ul"). Append (str); $ ('. Main_box '). ScrollTop ($ ('. Main_box ') [0].scrollheight]; }); } } );}

    Flashing is the page refresh, see if there is a re-render the page code.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.