jQuery实现ajax

html部分:

<!DOCTYPE HTML>
<html>
<head>
<title>test</title>
<meta charset="utf-8" />
<script type="text/javascript" src="jquery-1.4.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(‘#button’).click(function(){
$(‘#load’).load(‘get.php’);
$.get(‘get.php’,function(back){
$(‘#get’).html(‘get:’+back);
});
$.post(‘get.php’,function(back){
$(‘#post’).html(‘post:’+back);
});
$.ajax({
type:’get’,
url:’get.php’,
data:’name=aaa’,
datatype:"text",
async:true,
timeout:1000,
success:function(back){
$(‘#ajax’).html(‘ajax:’+back);
}
});
});
});
</script>
</head>
<body>
<input type="button" id="button" value="确定" />
<div id="load"></div>
<div id="get"></div>
<div id="post"></div>
<div id="ajax"></div>
</body>
</html>

php部分:get.php


<?php echo 'success!'; ?>

发表评论