ajax同步处理

ajax同步处理,第1张

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代码:

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/586317.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-12
下一篇 2022-04-12

发表评论

登录后才能评论

评论列表(0条)

保存