POPLX_杀手 2015-06-16 02:53 采纳率: 80%
浏览 2100
已采纳

这段代码为何没有先执行最开始那个getHtml()函数?

 <!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
    <head>
        <title></title>
        <meta charset="utf-8">
        <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
        <link rel="stylesheet" href="css/fonts/font-awesome.min.css">
        <link rel="stylesheet" href="css/ui-box.css">
        <link rel="stylesheet" href="css/ui-base.css">
        <link rel="stylesheet" href="css/ui-color.css">
        <link rel="stylesheet" href="css/appcan.icon.css">
        <link rel="stylesheet" href="css/appcan.control.css">
        <link rel="stylesheet" href="2_2_content/css/main.css">
        <script src="js/jquery-1.11.1.min.js"></script>
        <script>
            window.uexOnload = function(type){
    uexWindow.setBounce(1);
    uexWindow.notifyBounceEvent(0,1);
    var json='{"textColor":"#000","imagePath":"res://refesh_icon.png","levelText":"更多","pullToReloadText":"拖动到底部","releaseToReloadText":"释放回原处","loadingText":"载入中..."}';
    uexWindow.setBounceParams(0, json);
    uexWindow.showBounceView("0","#00F", 1);
    var json2 ='{"textColor":"#fff","imagePath":"res://refesh_icon.png","levelText":"更多","pullToReloadText":"上拉到底部","releaseToReloadText":"松手回原处","loadingText":"载入中..."}';
    uexWindow.setBounceParams(1, json2);
    uexWindow.showBounceView("1","rgba(15, 155, 155, 100)", 1);
    uexWindow.onBounceStateChange = onBounceStateChange;
    }

    function onBounceStateChange(type, state){
    switch(type) {
                case 0:
                if (state == 2) {
                uexWindow.resetBounceView("0");
                uexWindow.open('2_1', '0', '2_1.html', 4, '', '', 4,100);
                }
                break;
                case 1:
                if (state == 2) {
                uexWindow.resetBounceView("1");
                }
                }
                }
        </script>
        <script>
        var arrData;  //从服务器获得的数据
        //arrData.pop();//删除数据
        //arrData.push({"picture" : OO+".jpg","ABC" : "abcd12",});//添加数据
        var arr;     //从 arrData解析出来的数据 
        var arr_LOST; //最终数据  
        var num; //判断有几组12个数据
        var length;
        var m_length;
        TheArray = new Array();   //先声明一维
        m = 0;//表明当前应该执行第几组,默认从最开始的第0组开始 

        //创建xmlHttp对象,验证网络状况
   </script>

   <script>

    function getHtml(){
      $.get("http:// 192.168.0.21:19842/rt/YearServlet",function(data,status){
      arrData=data;
      arr = eval('('+arrData+')');  //LX:只需要对arr进行修改,可以alert出来看看这个数组
      alert("CCC"+arr);
      arr_LOST=arr;
    });         

 }
   getHtml();
 </script>
    </head>
    <body class="um-vp bc-bg" ontouchstart>
        <div class="ub ub-ver">
            <div class="umar-a1">
                <div class="sc-bg-active uinput ub ub-f1  bc-border uba">
                    <div class="uinn fa fa-search sc-text"></div>
                    <input placeholder="搜索你想知道的" type="text" class="ub-f1">
                    <button class="btn   bc-text-head   Mybutton" style="color:black; font-weight:bold;" onclick="A()">搜索</button>
                </div>
            </div>
        </div>
        <div style="width: 100%" id="page"></div>
        <div  class=" ub-ver uinn-p1" id="pictureList"></div>

        <script src="js/appcan.js"></script>
        <script src="js/appcan.control.js"></script>
    </body>
    <script>
        alert('ABC'+arr);
    </script>

    <script>
        appcan.ready(function() {
            appcan.initBounce();


        })
    </script>
</html>

这段代码为何没有先执行getHtml();并弹出alert("CCC"+arr);而是先执行alert('ABC'+arr);再执行的alert("CCC"+arr);
如何先执行alert('ABC'+arr);呢?

  • 写回答

5条回答

  • meifalong 2015-06-16 02:58
    关注
    时间估计话费在这个请求上了 $.get("http:// 192.168.0.21:19842/rt/YearServlet",function(data,status){
    
    
        你把 alert("CCC"+arr);放在这个请求前试试
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog