使用XMLHttpRequest中getResponseHeader()方法是,出现中文乱码的问题。 Server端代码: ... response.setContentType("text/html; charset=UTF-8"); response.setHeader("objNameForRel", objName.toString());//ojbName:中文123 .. JS端代码: ... xhr.getResponseHeader('rowObjNameForRel');//取到的值是??123 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript"></script> <script> function doSubmit(){ var param=$("#date").serialize(); alert($(".easyui-datebox").val()); } </script> </head> <body> <input id="date" class="easyui-datebox" name="date"></input> <input type="button" onclick="doSubmit()" value="查看"/><br/> </body> </html>
|