jQuery中ajax
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>ajax-jquery</title>
</head>
<body>
<script src="jquery.js"></script>
<script>
$.ajax({
url:'time.php',
type:"get",
data:{id:1,name:'zs'},
dataType:'json',
beforeSend:function(xhr){
console.log('beforeSend'.xhr)
},
success:function(res){
console.log(res)
},
error:function(xhr){
console.log('error',xhr)
},
complete:function(xhr){
console.log('complete',xhr)
}
})
$.get('json.php', {id:1}, function(res){
console.log(res)
})
$.post('json.php', {id:1}, function(res){
console.log(res)
})
$.getJSON('json.php', {id:1}, function(res){
console.log(res)
})
</script>
</body>
</html>