$.ajax({
//访问地址
url:'/path/to/file',
//访问方式,一般有GET或POST两种
type:'defaultGET(Othervalues:POST)',
//返回的数据格式,这个是可选参数,jquery回默认判断返回参数的类型
dataType:'default:IntelligentGuess(Othervalues:xml,json,script,orhtml)',
//发送的数据
data:{
param1:'value1',
param2:'value2'
},
})
//成功后的处理函数,res为服务器返回的数据
.done(function(res){
console.log("success");
})
//失败后的处理函数
.fail(function(){
console.log("error");
})
//结束后的处理函数,不管成功失败都执行
.always(function(res){
console.log("complete");
});