---
title: "又见 Jquery Ajax Post乱码"
author: "msnvip"
date: "2009-10-13T15:16:21Z"
tags: []
slug: "jquery-ajax-post"
draft: false
lastmod: "2009-10-13T15:20:43Z"
id: 487016
url: "https://msnvip.iteye.com/blog/487016"
---

```
var contents = encodeURIComponent(document.getElementById("content-"+id).value);
	//var contents = document.getElementById("content-"+id).value;
	var castellanId = document.getElementById("castellan-"+id).value;

	alert(contents);
	
	if (handleType == 'read') {
		$.post('handleSuggestDomainAction.action', {
		    sbt: 'sbrd',
		    content: contents,
		    cid: castellanId,
		    sgId: id
		}, function() {
		    //alert('哈哈.回复/处理成功!');
		    window.location.href =window.location.href;
          	window.location.href.reload();
		    //window.location.reload();
		});				
	}
```

 

 

 环境: Jquery1.3.2 ,Struts2

 

页面:

jsp中,改成红色显示的那样

 

var contents = encodeURIComponent(document.getElementById("content-"+id).value);

服务器端:

contentCn = URLDecoder.decode(content, "UTF-8");

 

乱码解决..

以前记得要页面上 encode 2次的.貌似记错了?