话说千遍淡如水,不如代码来一通。
Axios post:
let params = new URLSearchParams();
params.append('id',xx)
axios({
url:'http://127.0.0.1:8000/userctrl/shoucang',
method:'post',
data:params,
responseType:"text",
})
.then(function(obj){
})
//后端取值:
id = request.POST.get('id')
Axios get:
axios({
url:'http://127.0.0.1:8000/userctrl/shoucang',
method:'get',
params:{'id':xx},
responseType:"text",
})
.then(function(obj){
})
//后端取值:
id= request.GET.get('id')
Ajax post:
$.ajax({
url:"http://127.0.0.1:8000/userctrl/shoucang",
data:{'id':xx},
type:"post",
async:false,
dataType:"text",
success:function(obj){
console.log(obj)
}
})
//后端取值:
id = request.POST.get('id')
Ajax get:
$.ajax({
url:"http://127.0.0.1:8000/userctrl/shoucang",
data:{'id':xx},
type:"get",
async:false,
dataType:"text",
success:function(obj){
console.log(obj)
})
//后端取值:
id= request.GET.get('id')
来源:oschina
链接:https://my.oschina.net/u/4362820/blog/3574696