ajax 請求後瀏覽器報400 bad request
阿新 • • 發佈:2019-02-19
原因:ajax中url有問題,與後臺的引數型別不匹配;例如前端傳的引數為字串,後端為整形
解決辦法:排除法,不斷更換url篩選錯誤
參考http://www.xker.com/page/e2009/0116/68445.html
1、
encodeURIComponent(”[string]“)
decodeURIComponent(”[encodedString]“)
2、
encodeURI(”[string]“)
decodeURI(”[encodedString]“)
3、
escape(”[string]“)
unescape(”[encodedString]“)
Note:
a、The both of 1 and 2 encodes/decodes in “utf-8″
b、The both of 1 and 2 can not encode _-~*.’
c、The difference of 1 and 2 is 2 can not encoding /?&+=$@,;
d、The 3 encodes/decodes in “ISO Latin”
附註:URL編碼規則
1、對每個位元組進行編碼;
2、空格轉為”+”號;
3、安全字元不編碼。安全字元:大小寫英文字母(a-z以及A-Z) 阿拉伯數字(0-9) \’ ( ) * - . _ !
4、其他位元組以十六進位制顯示並加”%”字首,例如用%25代表%號。