Home > Web Front-end > JS Tutorial > body text

Double-layer ajax nesting (can be multi-layered) usage examples

亚连
Release: 2018-05-25 10:29:24
Original
2584 people have browsed it

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=&#39;00000&#39;>请选择</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(&#39;error&#39;);  
  }, 
  success:onchangecal 
  }); 
  } 
  } 
  }
  if(chooseIdTypeOne==2){
  for(var i=0;i<data.length;i++){ 
   str+="<option value=&#39;"+data[i].UID+"&#39;>"+data[i].NAME+"</option>"
  } 
  }
  if(chooseIdTypeOne==3){
  for(var i=0;i<data.length;i++){ 
   str+="<option value=&#39;"+data[i].UID+"&#39;>"+data[i].NAME+"</option>"
  } 
  }
  if(chooseIdTypeOne==4){
  for(var i=0;i<data.length;i++){ 
   str+="<option value=&#39;"+data[i].UID+"&#39;>"+data[i].NAME+"</option>"
  } 
  }
  if(chooseIdTypeOne==5){
  for(var i=0;i<data.length;i++){ 
   str+="<option value=&#39;"+data[i].UID+"&#39;>"+data[i].NAME+"</option>"
  } 
  }
  if(chooseIdTypeOne==6){
  for(var i=0;i<data.length;i++){ 
   str+="<option value=&#39;"+data[i].UID+"&#39;>"+data[i].NAME+"</option>"
  } 
  }
  if(chooseIdTypeOne==7){
  for(var i=0;i<data.length;i++){ 
   str+="<option value=&#39;"+data[i].UID+"&#39;>"+data[i].NAME+"</option>"
  } 
  }
  if(chooseIdTypeOne==8){
  for(var i=0;i<data.length;i++){ 
   str+="<option value=&#39;"+data[i].UID+"&#39;>"+data[i].NAME+"</option>"
  } 
  }
  if(chooseIdTypeOne==9){
  for(var i=0;i<data.length;i++){ 
   str+="<option value=&#39;"+data[i].UID+"&#39;>"+data[i].NAME+"</option>"
  } 
  }
  if(chooseIdTypeOne==10){
  for(var i=0;i<data.length;i++){ 
   str+="<option value=&#39;"+data[i].UID+"&#39;>"+data[i].NAME+"</option>"
  } 
  }
  if(chooseIdTypeOne==11){
  for(var i=0;i<data.length;i++){ 
   str+="<option value=&#39;"+data[i].UID+"&#39;>"+data[i].NAME+"</option>"
  } 
  }
  if(chooseIdTypeOne==12){
  for(var i=0;i<data.length;i++){ 
   str+="<option value=&#39;"+data[i].UID+"&#39;>"+data[i].NAME+"</option>"
  } 
  }
  if(chooseIdTypeOne==13){
  for(var i=0;i<data.length;i++){ 
   str+="<option value=&#39;"+data[i].UID+"&#39;>"+data[i].NAME+"</option>"
  } 
  }
  $("#chooseIdTypeOnechdranone2").html(str);
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template