1. 程式人生 > >django中使用jquery ajax post資料出現403錯誤的解決辦法(兩種方法)

django中使用jquery ajax post資料出現403錯誤的解決辦法(兩種方法)



方法一:

在傳送post請求的html頁面前加入{% csrf_token %}

方法二:

在處理post資料的view前加@csrf_exempt裝飾符

例如

@csrf_exempt
def profile_delte(request): 
  del_file=request.POST.get("delete_file",'')