Home > Article > Backend Development > javascript - jquery gets value, ios and android get value problem
jquery can get the value, ios can’t get it, but android can
<code><script type="text/javascript"> var pageurl="{:U('App/Friends/page')}"; var tpl="{$tpl}App/Friends/Public/"; var headimgurl="{$person['headimgurl']}"; var openid="{$person['openid']}"; var uname="{$person['uname']}"; var classid="{$person['classid']}"; var isadmin="{$person['isadmin']}"; var isblack="{$person['isblack']}"; var arr=[0,10,20,30,60]; var contenturl="{:U('App/Friends/getcontent')}"; $(document).ready(function(){ $('.loading_box').attr('style','display:none'); ajaxform(); setInterval("ajaxform()",3000); }); </script> function ajaxform(){ var id=$(".main_box ul li:last-child").find('.delete_btn').attr('field');alert(id);alert(isadmin); $.ajax({ type:'POST', url:"{:U('App/Friends/ajaxform')}", data:{"openid":openid,"id":id}, dataType:"json", global:false, success:function(data){ $.each(data[1],function(e,a){ isblack=a; }); } });</code>
}
jquery can get the value, ios can’t get it, but android can
<code><script type="text/javascript"> var pageurl="{:U('App/Friends/page')}"; var tpl="{$tpl}App/Friends/Public/"; var headimgurl="{$person['headimgurl']}"; var openid="{$person['openid']}"; var uname="{$person['uname']}"; var classid="{$person['classid']}"; var isadmin="{$person['isadmin']}"; var isblack="{$person['isblack']}"; var arr=[0,10,20,30,60]; var contenturl="{:U('App/Friends/getcontent')}"; $(document).ready(function(){ $('.loading_box').attr('style','display:none'); ajaxform(); setInterval("ajaxform()",3000); }); </script> function ajaxform(){ var id=$(".main_box ul li:last-child").find('.delete_btn').attr('field');alert(id);alert(isadmin); $.ajax({ type:'POST', url:"{:U('App/Friends/ajaxform')}", data:{"openid":openid,"id":id}, dataType:"json", global:false, success:function(data){ $.each(data[1],function(e,a){ isblack=a; }); } });</code>
}
You comment on other things first, and only run this line when entering the page. I just tested it on iPhone version 7.2, and it works.
<code>var id=$(".main_box ul li:last-child").find('.delete_btn').attr('field');alert(id);</code>
Declare the function in the ready function.