1. 写Ajax代码
    $.ajax({
       url:'',
       type:'POST',
       contentType:'application/json',
       data:JSON.stringify({
             a:1,
             b:2
    
    })  
    
    })

     

  2. 在Django中接收
    #如果contentType写成application/json那么在request.POST中就没有数据了
    def ajax_json(requset):
        if request.method=='POST':
            ajax_json=request.body #请求报文中的请求体
        
             post_data=request.POST #只有在contentType=urlencode才有数据

     

相关文章:

  • 2022-12-23
  • 2022-01-19
  • 2022-12-23
  • 2021-12-26
  • 2021-07-16
  • 2021-12-26
猜你喜欢
  • 2022-02-02
  • 2021-12-26
  • 2022-12-23
  • 2022-01-15
  • 2021-12-07
  • 2022-12-23
相关资源
相似解决方案