jquery的ajax用serialize传值,后台接受,中文乱码解决方法
来源:互联网 发布:俄罗斯手机聊天软件 编辑:程序博客网 时间:2024/06/06 09:27
使用$('form').serialize()
方法遇到中文字符乱码的问题,查看jquery
源码发现:
serialize: function() { return jQuery.param( this.serializeArray() );}
再看param
方法中有这么一句
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
因为jquery
内部使用了encodeURIComponent
方法, 所以中文会变成%xx这种形式.
那么解决方法限简单, 再解码一次即可:
var result = decodeURIComponent($('form').serialize());
阅读全文
0 0
- jquery的ajax用serialize传值,后台接受,中文乱码解决方法
- JQuery Ajax中文乱码解决方法
- js ajax 前台到后台中文乱码的解决方法
- jquery的$('#theForm').serialize()获取表单数据,ajax传递到服务器中文乱码。
- ajax前台接受到的中文乱码
- jquery的 ajax返回值为中文时乱码解决方法
- jquery的 ajax返回值为中文时乱码解决方法
- jquery的ajax()函数传值中文乱码解决方法介绍
- jquery ajax 提交中文乱码解决方法
- jquery serialize传中文乱码解决方法
- jquery $("#form").serialize()传中文乱码解决方法
- jquery serialize传中文乱码解决方法
- jquery serialize传中文乱码解决方法
- jquery serialize传中文乱码解决方法
- jquery serialize传中文乱码解决方法
- 关于struts2后台接受jquery ajax提交的复杂对象
- 关于struts2后台接受jquery ajax提交的复杂对象
- jquery serialize方法中文乱码及解决办法
- 3344-->数据结构实验之二叉树五:层序遍历
- JVM、Java编译器和Java解释器
- Ubuntu16.04安装32位支持库
- ffmpeg编解码之图片转视频
- Java 生成二维码
- jquery的ajax用serialize传值,后台接受,中文乱码解决方法
- 简述Tomcat的日志系统
- oracle创建用户并给用户授权查询指定表或视图的权限
- 使用Python的数据类型(3)元组
- Redis介绍与安装
- c语言的可变参数函数实现与讲习
- 第二章 Spring MVC入门 —— 跟我学SpringMVC
- jQuery Object 和 Html Element之间的互换
- 两周学会Python 第02天(上午)