zoukankan      html  css  js  c++  java
  • IE内核发送ajax请求时不会将url中的参数编码

    有一次用户遇到创建文件,名称为中文时乱码的问题。

    经调查,发现用户使用的是国产浏览器ie模式

    抓取请求发现

    IE:

    键 值
    请求 POST /Handlers/CreateTxtFile.ashx?filename=阿斯达是.txt HTTP/1.1
    Accept */*
    Content-Type application/x-www-form-urlencoded; charset=UTF-8
    X-Requested-With XMLHttpRequest
    Referer http://mt.sogou.com/MobileCloud/Pages/IDE/pages/ide.html
    ...

    chrome:

    Remote Address:

    220.181.124.6:80

    Request URL:

    http://mt.sogou.com/Handlers/CreateTxtFile.ashx?filename=%E6%B5%8B%E8%AF%95%E6%B5%8B%E8%AF%95%E6%B5%8B%E8%AF%95-%E6%89%8B%E6%9C%BA.txt

    Request Method:

    POST

    ....

    可以发现ie浏览器是没有对url中的中文自动编码的。

    所以我们在页面中发送请求时一定要注意对参数进行 encodeURIComponent

  • 相关阅读:
    Python进阶08 生成器
    Python进阶07 迭代
    Python进阶06 列表推导
    Python进阶05 函数property
    Python基础14 集合
    支付宝支付和微信消息推送
    Redis
    django之contenttype
    数据分析系列
    IPython
  • 原文地址:https://www.cnblogs.com/tzyy/p/4727468.html
Copyright © 2011-2022 走看看