- ajax传递数据
js
var data = {'name':name,'province':province,'city':city,'area':area,'address':address,'phone':phone}
$.ajax({
url:'/save/',
type:'post',
data:data ,
dataType:'json',
success:function(data){
},
})
view.py
# 获取参数
name = request.POST.get('name',None)
- ajax向后端传递json数据
js
var info = []
info1 = {'name':'名称1','age':20}
info2 = {'name':'名称2','age':18}
info.push(info1)
info.push(info2)
$.ajax({
url:'/save/',
type:'post',
data:JSON.stringify(info) ,
dataType:'json',
success:function(data){
},
})
view.py
data = json.loads(request.body)
for v in data:
print(v)