码迷,mamicode.com
首页 > 其他好文 > 详细

补2017.5.14

时间:2017-05-26 09:25:49      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:sync   post   jquer   UI   false   rom   script   stat   ext   

三级联动

<script src="jquery-1.8.2.min.js"></script>
<script src="Area.js"></script>
</head>

<body>
<h1>显示数据</h1>

<select id="sel1">

</select>
<select id="sel2">

</select>
<select id="sel3">

</select>

 

</body>
<script type="text/javascript">
$(document).ready(function(e) {

//异步AJAX
//异步和同步
var pcode = "0001";

$.ajax({
async:false,
url:"chuli1.php",
data:{pcode:pcode},
   type:"POST",
dataType:"TEXT",
complete: function(){},
beforeSend: function(){},
error: function(){},
success: function(data){
var hang = data.split("|");
var str = "";
for(var i=0;i<hang.length;i++)
{
var lie = hang[i].split("^");
str = str +"<option value=‘"+lie[0]+"‘>"+lie[1]+"</option>";
}
$("#sel1").html(str);

}
});

});
</script>
<script type="text/javascript">
$(document).ready(function(e) {

//异步AJAX
//异步和同步
var pcode = "11";

$.ajax({
async:false,
url:"chuli2.php",
data:{pcode:pcode},
   type:"POST",
dataType:"TEXT",
complete: function(){},
beforeSend: function(){},
error: function(){},
success: function(data){
var hang = data.split("|");
var str = "";
for(var i=0;i<hang.length;i++)
{
var lie = hang[i].split("^");
str = str +"<option value=‘"+lie[0]+"‘>"+lie[1]+"</option>";
}
$("#sel2").html(str);

}
});

});
</script>
<script type="text/javascript">
$(document).ready(function(e) {

//异步AJAX
//异步和同步
var pcode = "1101";

$.ajax({
async:false,
url:"chuli3.php",
data:{pcode:pcode},
   type:"POST",
dataType:"TEXT",
complete: function(){},
beforeSend: function(){},
error: function(){},
success: function(data){
var hang = data.split("|");
var str = "";
for(var i=0;i<hang.length;i++)
{
var lie = hang[i].split("^");
str = str +"<option value=‘"+lie[0]+"‘>"+lie[1]+"</option>";
}
$("#sel3").html(str);

}
});

});

注意好同步和异步。

chuli1的代码

//给我一个父级代号,返回该父级代号下所有的子地区

 

<?php
$pocde=$_POST["pcode"];
require "./DBDA.class.php";
$db = new DBDA();

$sql = "select areacode,areaname from chinastates where parentareacode=‘{$pocde}‘";

echo $db->strquery($sql);

 

补2017.5.14

标签:sync   post   jquer   UI   false   rom   script   stat   ext   

原文地址:http://www.cnblogs.com/nzhcww/p/6906855.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!