php
<?php
header('HTTP/1.1 500 Server Interval Error');
//header('Content-Type: text/plain');
$uname = $_REQUEST['uname'];
echo 'Hello: '.$uname;
?>
<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta charset="utf-8" />
</head>
<body>
<h1>jQuery对AJAX的封装——$.ajax</h1>
<script src="js/jquery-1.11.3.js"></script>
<script>
$(function(){
//发起异步请求
$.ajax({
type: 'GET', //POST/HEAD/PUT/DELETE...
url: '8-server.php',
data: {uname:'唐牧', age:20}, //'uname=tom&age=20'
dataType: 'text', //html/script/xml/json/jsonp
beforeSend: function(){
console.log('AJAX请求即将发送...');
},
success: function(){
console.log('AJAX请求得到成功的响应数据...');
console.log(arguments);
},
error: function(){
console.log('AJAX请求得到错误的响应数据...');
console.log(arguments);
},
complete: function(){
console.log('AJAX请求完成,不论成功/失败...');
}
});
});
</script>
</body>
</html>