php 獲取不到post的值

通常在ajax提交的時候出現這種狀況php

當咱們在ajax參數設置   contentType: 'application/json; charset=utf-8', 用file_get_contents("php://input")獲取值 $_POST是獲取不到的ajax

1.檢查頭信息content-type是否是爲「content-type:application/x-www-form-urlencoded" 這種傳輸是以表單的方式提交數據php使用$_POST方式接受。json

2.若是頭信息content-type是否是爲「content-type:application/json"這種傳輸是以json方式提交數據,php須要使用file_get_contents("php://input")獲取輸入流的方式接受

app

相關文章
相關標籤/搜索