---
title: "jquery ajax中文乱码处理"
author: "hzp"
date: "2012-11-28T14:37:10Z"
tags: []
categories: ["Web前端"]
slug: "jquery-ajax"
draft: false
lastmod: "2012-11-28T14:37:10Z"
id: 1736617
url: "https://hzp.iteye.com/blog/1736617"
---

1.现象

利用jquery ajax提交表单，在firefox下后台获取中文正常，但在IE下后台获取中文乱码

2.问题根源

查看Header，发现Entity中的Content-Type存在差异

在Firefox中，Content-Type指定了字符集为utf-8。

![](http://www.jb51.net/upload/201007/20100702234521668.png)

而在IE8中，却没有任何的字符集指定。

![](http://www.jb51.net/upload/201007/20100702234530601.png)

3.解决办法

$.ajax({  
            url:"${basePath}seo!save.action",  
            type:"post",   
            dataType:"json",  
            data:$("#myForm").serialize(),  
            contentType: "application/x-www-form-urlencoded; charset=utf-8", //显示设置编码  
            success:function(data){  
                alert("修改成功!");   
            },  
            failure:function(data){  
                alert("修改失败!");  
            }   
        });