1. 程式人生 > >ajax(post)

ajax(post)

url pos function con before end name let html

$.ajax({
url:‘/comm/test1.php‘,
type:‘POST‘,           //GET
async:true,         //或false,是否異步
data:{
name:‘yang‘,age:25
},
timeout:5000,        //超時時間
dataType:‘json‘,      //返回的數據格式:json/xml/html/script/jsonp/text
beforeSend:function(xhr){
console.log(xhr)
console.log(‘發送前‘)
},
success:function(data,textStatus,jqXHR){
console.log(data)
console.log(textStatus)
console.log(jqXHR)
},
error:function(xhr,textStatus){
console.log(‘錯誤‘)
console.log(xhr)
console.log(textStatus)
},
complete:function(){
console.log(‘結束‘)
}
})

ajax(post)