HTTP請求過程中,get請求:表單參數以name=value&name1=value1的形式附到url的后面;
post請求:表單參數是在請求體中,也是name=value&name1=value1的形式在請求體中。
POST表單請求提交時,使用的Content-Type是application/x-www-form-urlencoded,而使用原生AJAX的POST請求如果不指定請求頭RequestHeader,默認使用的Content-Type是text/plain;charset=UTF-8。
在html中form的Content-type默認值:Content-type:application/x-www-form-urlencoded
如果使用ajax請求,在請求頭中出現 request payload導致參數的方式改變了 ,那么解決辦法就是:
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
或者使用ajax設置:
$.ajaxSetup({contentType: 'application/x-www-form-urlencoded'});
這樣,問題就可以解決。
