JQuery中Ajax的使用:
$.ajax({
url:'請求地址',
type:'請求響應(yīng)方式',
data:'請求的數(shù)據(jù)(用json表示)',
dataType:'響應(yīng)體傳過來的數(shù)據(jù)格式類型(json)',
success:function(res){
? ? console.log(res);
????}
error:function(){
console.log(請求失敗);
????}
complete:function(){
? ? console.log(請求結(jié)束);
????}? ?
});
JQuery中g(shù)et,post代碼
$.get('請求地址',{id:1},function(res){
? ? console.log(res);
});
$.post('請求地址',{id:1},function(res){
console.log(res);
});