2.中文处理:
例 2.1
<html>
<head>
<title></title>
<script language="JavaScript">
var xmlrequest;
function createXMLHttpRequest() {
if(window.ActiveXObject){//ie
alert("we are using microsoft ActiveXObject");
xmlrequest = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlrequest = new XMLHttpRequest();
}
}
createXMLHttpRequest();
function postSend(value) {
var uri = "servlet21";
xmlrequest.open("POST", uri, true);
/*马克-to-win:through experiment, we find that we must use the
following statement, otherwise post can not work.
form-urlencoded是Ajax第一次编码,公认的Ajax是用的UTF-8编
码的,所以第二次编码是用的UTF-8编的码。*/
xmlrequest.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
xmlrequest.onreadystatechange = processResponse;
xmlrequest.send("test=" + value);
更多请见:http://www.mark-to-win.com/tutorial/js_8_ajaxChinese.html