<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>使用getJSON()方法异步加载JSON格式数据</title>
<script type="text/javascript" src="jquery-1.10.2.min.js"></script>
<style type="text/css">
.title{
width: 300px;
height: 50px;
line-height: 50px;
color: #fff;
font-weight: bold;
background-color: green;
}
.fl{
float: left;
}
.fr{
float: right;
}
ul li{ list-style-type: none;}
</style>
</head>
<body>
<div id="divtest">
<div class="title">
<span class="fl">检测数字的奇偶性</span>
<span class="fr"><input id="btnCheck" type="button" value="检测"/></span>
</div>
<ul>
<li>
请输入一个数字
<input id="txtNumber" type="text" size="12" />
</li>
</ul>
</div>
<script type="text/javascript">
$(function(){
$("#btnCheck").bind("click",function(){
$.post("data/check.php",{
num:$("#txtNumber").val()
},function(data){
$("ul").append("<li>你输入的<b>"+$("#txtNumber").val()+"</b><b>是"+data+"</b></li>")
});
});
});
</script>
</body>
</html>