首页 > Web开发 > 详细

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

时间:2020-07-02 14:45:18      阅读:44      评论:0      收藏:0      [点我收藏+]

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>

 

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

原文:https://www.cnblogs.com/nongfusanquan/p/13224314.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!