基本信息
源码名称:jsp JSON入门示例代码
源码大小:1.16M
文件格式:.zip
开发语言:C#
更新时间:2016-05-23
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>city.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/json2.js"></script>
<script type="text/javascript">
function getXmlHttpRequest(){
var xhr = null;
if((typeof XMLHttpRequest)!='undefined'){
xhr = new XMLHttpRequest();
}else {
xhr = new ActiveXObject('Microsoft.XMLHttp');
}
return xhr;
}
function change(v1){
var xhr = getXmlHttpRequest();
xhr.open('post','city.do',true);
xhr.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
xhr.onreadystatechange=function(){
if(xhr.readyState == 4){
var txt = xhr.responseText;
var citys = txt.parseJSON();
document.getElementById('s2').innerHTML = '';
for(i=0;i<citys.length;i ){
var op =
new Option(citys[i].cityName,
citys[i].cityValue);
document.getElementById('s2').options[i] = op;
}
}
};
xhr.send('name=' v1);
}
</script>
</head>
<body>
<select id="s1" style="width: 120px;" onchange="change(this.value);">
<option value="sh">
上海
</option>
<option value="bj">
北京
</option>
</select>
<select id="s2" style="width: 120px;">
</select>
</body>
</html>