Home >Web Front-end >JS Tutorial >Double-layer ajax nesting (can be multi-layered) usage examples
This article mainly introduces the usage of double-layer ajax nesting (can be multi-layered), and analyzes the related usage skills of Ajax nesting with examples. It can realize the function of multi-layer nesting and has certain reference value. Friends in need You can refer to the example below
This article describes the usage of double-layer ajax nesting (can be multi-layered). Share it with everyone for your reference. The details are as follows:
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="<option value='00000'>请选择</option>"; 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<data.length;i++){ str+="<option value='"+data[i].UID+"'>"+data[i].NAME+"</option>" } } if(chooseIdTypeOne==3){ for(var i=0;i<data.length;i++){ str+="<option value='"+data[i].UID+"'>"+data[i].NAME+"</option>" } } if(chooseIdTypeOne==4){ for(var i=0;i<data.length;i++){ str+="<option value='"+data[i].UID+"'>"+data[i].NAME+"</option>" } } if(chooseIdTypeOne==5){ for(var i=0;i<data.length;i++){ str+="<option value='"+data[i].UID+"'>"+data[i].NAME+"</option>" } } if(chooseIdTypeOne==6){ for(var i=0;i<data.length;i++){ str+="<option value='"+data[i].UID+"'>"+data[i].NAME+"</option>" } } if(chooseIdTypeOne==7){ for(var i=0;i<data.length;i++){ str+="<option value='"+data[i].UID+"'>"+data[i].NAME+"</option>" } } if(chooseIdTypeOne==8){ for(var i=0;i<data.length;i++){ str+="<option value='"+data[i].UID+"'>"+data[i].NAME+"</option>" } } if(chooseIdTypeOne==9){ for(var i=0;i<data.length;i++){ str+="<option value='"+data[i].UID+"'>"+data[i].NAME+"</option>" } } if(chooseIdTypeOne==10){ for(var i=0;i<data.length;i++){ str+="<option value='"+data[i].UID+"'>"+data[i].NAME+"</option>" } } if(chooseIdTypeOne==11){ for(var i=0;i<data.length;i++){ str+="<option value='"+data[i].UID+"'>"+data[i].NAME+"</option>" } } if(chooseIdTypeOne==12){ for(var i=0;i<data.length;i++){ str+="<option value='"+data[i].UID+"'>"+data[i].NAME+"</option>" } } if(chooseIdTypeOne==13){ for(var i=0;i<data.length;i++){ str+="<option value='"+data[i].UID+"'>"+data[i].NAME+"</option>" } } $("#chooseIdTypeOnechdranone2").html(str); }
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
Detailed explanation of ajax synchronization and asynchronousness in jquery
Ajax asynchronous upload in jquery
How to implement ASP.NET and Ajax
The above is the detailed content of Double-layer ajax nesting (can be multi-layered) usage examples. For more information, please follow other related articles on the PHP Chinese website!