52,782
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript" src="jquery.min.js"></script>
<script type="text/javascript">
var indexdata;
$(document).ready(function(){
$("#click1").click(function(){
indexdata='news.json';
showdata();
})
$("#click2").click(function(){
indexdata='web.json';
showdata();
})
})
function showdata(){
$.ajax({
url:indexdata,
type:'GET',
dataType:'json',
timeout:10000,
error:function(){
alert('异步通讯失败!!');
},
success:function(json){
$("#show").html(json[0].text);
}
})
}
</script>
</head>
<body style="background-color:#cccccc;">
<div id="show" style="border:1px solid #000000;width:200px;height:300px;margin-left:auto;margin-right:auto;">1231333</div>
<div style="width:200px;height:50px;margin-left:auto;margin-right:auto;"><input type="button" value="按钮1" id="click1"></input><input type="button" value="按钮2" id="click2" ></input></div>
</body>
</html>