nongfusanquan

jQuery使用serialize获取form表单数据,中文乱码问题

jQuery中使用serialize时获取form表单数据,会将表单中的中文进行转码

<form>
    <input type="input" id="a1" name="a1" value=""/><br>
    <select>
          <option value="0">选项一</option>
          <option vlaue="1">选项二</option>
    </select>
     <input id="submit" type="button" value="提交" name/>
</form>
<script>
    $(\'#submit\').click(function(){
        var t = $(\'form\').serialize();
        document.write(t);//输入中文将被转码
        //解决
        var d = decodeURIComponent(t);
        document.write(d);//转码
    })
</script>

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-01-30
  • 2021-11-28
  • 2022-12-23
  • 2022-02-05
猜你喜欢
  • 2021-05-27
  • 2022-01-07
  • 2021-10-07
  • 2021-08-29
  • 2021-11-27
  • 2021-12-10
相关资源
相似解决方案