日期:2014-05-16  浏览次数:20722 次

ajax提交中文数据乱码问题

背景:用jquery的ajax方式提交中文参数的时候,在后台获取到的是乱码。

?

解决办法:在提交的时候,指定编码方式

jQuery.ajax({ 
			url: "<%=request.getContextPath()%>/attachment/attachmentAddForm_check.jsp?ACT=Check", 
			type: "post", 
			dataType: "xml", 
			contentType: "application/x-www-form-urlencoded; charset=utf-8",
			data:{fileName:fName},
			success:callback_checkFileName
			}); 
?