话不多bb直接上代码
html 代码:
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
</head>
<body>
<div id="myDiv">使用ajax改变此内容</div>
<a href="javascript:void(0);" onclick="show('index.php')">点击</a>
</body>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
function show(url){
var html='';
$.ajax({
url:url,
type:'get',
success:function(data){
alert(data);
html = '<p>'+data+'</p>';
$('#myDiv').html(html);
}
})
}
</script>
</html>
index.php代码:
<?php
$a ='Hollow world!';
echo $a;
?>