加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ajax 请求后浏览器报400 bad request

发布时间:2020-12-16 00:32:12 所属栏目:百科 来源:网络整理
导读:原因:ajax中url有问题,与后台的参数类型不匹配;例如前端传的参数为字符串,后端为整形 解决办法:排除法,不断更换url筛选错误 参考http://www.xker.com/page/e2009/0116/68445.html 1、 encodeURIComponent(”[string]“) decodeURIComponent(”[encoded

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读