ajax请求数据get、post

 

ajax请求数据get、post

post请求案例

$.ajax({
   type:"post" ,
   url:"请求地址" ,
   data:{'username':username,'password':password} ,
   contentType:'application/json',
   success:function(res){
       if(res.code == 200){
       }        
    },
    error:function(){
      csonsole.log('请求出错')
    }
}

get请求

$.ajax({
   type:"get",
   url:"链接地址",
   success:function(res){
    if(res.code == 200){
      alert(res.message)
    }
   },
   error:function(){
    console.log('请求出错')
   } 
})

有问题,请加群讨论:854184700

原文地址:https://www.cnblogs.com/yaosusu/p/13195417.html