jQuery $ajax 传中文数据到action乱码解决方法
2012-09-21 17:41
621 查看
前端代码:
后台代码:
vararticleId=$("#c_articleId").val(); vartoId=$("#c_to").val(); varcontent=$("#c_content").val();//conten的值是中文 $.ajax({ method:'post', url:'<%=path%>/ajaxAction_doAddComment.action', contentType:"application/json;charset=utf-8", data:"comment.article.id="+articleId+"&comment.toUser.id="+toId+"&comment.content="+encodeURI(encodeURI(content)),//对content进行两次encodeURI方法 dataType:'json', cache:false, success:function(data){ alert(data.content+"---"+data.publishTime); } });
后台代码:
comment.setContent(URLDecoder.decode(comment.getContent(),"utf-8"));//对content值进行解码
相关文章推荐
- jquery中ajax方法提交数据时,中文乱码问题解决。
- jquery.ajax的url中传递中文乱码问题的解决方法
- jquery之getJSON方法获取中文数据乱码解决方法
- JQuery的Ajax中Post方法传递中文出现乱码的解决方法
- Ajax $.ajax() 提交数据出现中文乱码的时候解决方法
- JQuery中Ajax的Post提交在IE下中文乱码的解决方法
- jquery的ajax()函数传值中文乱码解决方法介绍
- 页面编码为GBK时 jquery 提交ajax数据完美解决中文乱码方案
- Asp中使用JQuery的AJAX提交中文乱码解决方法
- Ajax融合struts2过程中,action类回传给客户端中文数据出现问号乱码的解决办法
- JQuery中Ajax提交在IE下中文乱码的解决方法
- 页面编码为GBK时 jquery 提交ajax数据完美解决"中文乱码"方案
- jquery的ajax()函数传值中文乱码解决方法介绍
- jquery的ajax()函数传值中文乱码解决方法介绍
- jquery的ajax()函数传值中文乱码解决方法介绍
- jquery的ajax()函数传值中文乱码解决方法介绍
- jquery的 ajax返回值为中文时乱码解决方法
- 页面编码为GBK时_jquery_提交ajax数据完美解决中文乱码方案
- Jquery的ajax在IE提交数据乱码解决方法
- jquery的 ajax返回值为中文时乱码解决方法