`

ajax 请求后浏览器报400 bad request

 
阅读更多

原因: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代表%号。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics