zoukankan      html  css  js  c++  java
  • ajax同步处理(使得JS按顺序执行)

    在项目中碰到一个问题:

    图一:

    图二:

    函数1代码:这里是因为有ajax请求,默认的是异步的

    //点击分页页码,请求后台返回对应页码的数据
    function getdata(fewPage,flag,content){
       $.getJSON(getUrl()+'/myAccount/getMyOrders.do?curPage='+fewPage+'&flag='+flag+'&content='+content, function (data) {
           orderCount1 = data.count1;
           orderCount2 = data.count2;
           orderCount3 = data.count3;
           orderCount4 = data.count4;
           var Data = data.insuranceDetailsVOs;
            
           $(".wait_pay").html(orderCount1);
           $(".already_pay").html(orderCount2);
           $(".Stop_keep").html(orderCount3);
           $(".On").html(orderCount4);
           
           var That_Page = fewPage;
           var orderCount;
           $('#Order_information').html("");
           for(var i=0;i<Data.length;i++){
               if(flag == 0){
                   var orderstate="";
                      if(Data[i].baseinfor.orderstate==30){
                          orderstate="已下单";
                      }else{
                          orderstate="待支付";
                      }
                      orderCount=orderCount1;
                      addPolicyInfo(Data[i],orderstate);
               }else if(flag == 1){
                   var orderstate="";
                      if(Data[i].baseinfor.orderstate==50){
                          orderstate="已支付";
                      }else if(Data[i].baseinfor.orderstate==60){
                          orderstate="已生效";
                      }else{
                          orderstate="已配送";
                      }
                      orderCount=orderCount2;
                      addPolicyInfo(Data[i],orderstate);
               }else if(flag == 2){
                   var orderstate="";
                   if(Data[i].baseinfor.orderstate==10){
                          orderstate="待定";
                      }else{
                          orderstate="已报价";
                      }
                   orderCount=orderCount3;
                   addPolicyInfo(Data[i],orderstate);
               }else if(flag == 3){
                   orderCount=orderCount4;
                   var orderstate = "已撤销";
                   addPolicyInfo(Data[i],orderstate);
               }
           }
           var Last_Page;
           if(typeof(orderCount)==undefined || orderCount==null || orderCount==""){
               Last_Page = 1;
           }else{
               Last_Page = parseInt(orderCount/10)+parseInt(orderCount%10>0?1:0);
           }
           Pager(That_Page,Last_Page);
       });
    }

    函数2代码:

  • 相关阅读:
    Cocos 更新时反复杀进程,导致差异更新失效的Bug
    Cocos 编译android-studio
    Could not resolve all dependencies for configuration ':classpath'
    MAC Gradle 下载的问题
    命令行创建 keystore
    应用间共享文件 FileProvider
    Android jks 签名文件 生成
    Gradle 离线 安装
    信息
    Cocos Lua的Touch 点击事件添加
  • 原文地址:https://www.cnblogs.com/ldbangel/p/6179963.html
Copyright © 2011-2022 走看看