2个ajax嵌套会卡主,双层ajax嵌套(可多层)用法实例

function addbus()

{

//清除a标签中的所有元素

// $("#s1").remove();

var chooseIdTypeOne =$("#chooseIdTypeOne2").find("option:selected").val();

$.ajax({

url : "/ftcms/changeProject.do?getOriginal&OriginalName="+chooseIdTypeOne,

data : null, // 参数

type : "post",

cache : false,

dataType : "json", //返回json数据

error: function(){

//document.getElementById("chooseIdTypeOnechdranone").options.length = 0;

alert('error');

},

success:onchangecal

});

}

function onchangecal(data){

var chooseIdTypeOne =$("#chooseIdTypeOne2").find("option:selected").val();

document.getElementById("chooseIdTypeOnechdranone2").options.length = 0; //清空原有的option

var str="请选择";

if(chooseIdTypeOne==1){

$.ajax({

url : "/ftcms/changeProject.do?getOriginal&OriginalName="+chooseIdTypeOne,

data : null, // 参数

type : "post",

cache : false,

dataType : "json", //返回json数据

error: function(){

//document.getElementById("chooseIdTypeOnechdranone").options.length = 0;

alert('error');

},

success:onchangecal

});

}

}

}

if(chooseIdTypeOne==2){

for(var i=0;i

str+=""+data[i].NAME+""

}

}

if(chooseIdTypeOne==3){

for(var i=0;i

str+=""+data[i].NAME+""

}

}

if(chooseIdTypeOne==4){

for(var i=0;i

str+=""+data[i].NAME+""

}

}

if(chooseIdTypeOne==5){

for(var i=0;i

str+=""+data[i].NAME+""

}

}

if(chooseIdTypeOne==6){

for(var i=0;i

str+=""+data[i].NAME+""

}

}

if(chooseIdTypeOne==7){

for(var i=0;i

str+=""+data[i].NAME+""

}

}

if(chooseIdTypeOne==8){

for(var i=0;i

str+=""+data[i].NAME+""

}

}

if(chooseIdTypeOne==9){

for(var i=0;i

str+=""+data[i].NAME+""

}

}

if(chooseIdTypeOne==10){

for(var i=0;i

str+=""+data[i].NAME+""

}

}

if(chooseIdTypeOne==11){

for(var i=0;i

str+=""+data[i].NAME+""

}

}

if(chooseIdTypeOne==12){

for(var i=0;i

str+=""+data[i].NAME+""

}

}

if(chooseIdTypeOne==13){

for(var i=0;i

str+=""+data[i].NAME+""

}

}

$("#chooseIdTypeOnechdranone2").html(str);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值