时间:2021-07-01 10:21:17 帮助过:44人阅读
<html>
<head><title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" src="a.js" charset="utf-8"></script>
</head>
<body>
<span id="show"></span>
<form name="aForm">
<input type="text" name="name"><br>
<input type="button" name="btn" value="ok" onclick="aa()">
</form>
<script language="javascript">
<!--
function aa(){
var o = new Ajax();
o.url = "a.php";
o.parseParameters(document.all.aForm);
o.post();
}
-->
</script>
</body>
</html>
a.js
代码如下:
function getXMLHTTPRequest(){
var xmlHttp;
if(window.ActiveXObject){
try{
xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
}catch(e){
try{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
xmlHttp = false;
}
}
}else{
try{
xmlHttp = new XMLHttpRequest();
}catch(e){
xmlHttp = false;
}
}
if(!xmlHttp){
return false;
}else{
return xmlHttp;
}
}
function Ajax(){
this.url;
this.params = "";
this.parseParameters = function(thisform){
for(var i = 0; i < thisform.elements.length; i++){
var e = thisform.elements[i];
this.params += (e.name + "=" + e.value);
if(i != (thisform.elements.length - 1))
this.params += "&";
}
};
AjaxObj = getXMLHTTPRequest();
AjaxObj.onreadystatechange = processRequest;
this.post = function(){
AjaxObj.open("post", this.url, true);
AjaxObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=utf-8');
if(this.params.length > 0)
AjaxObj.send(this.params);
else
AjaxObj.send();
}
}
function processRequest(){
if(AjaxObj.readyState == 4){
if(AjaxObj.status == 200){
if(AjaxObj.responseText != ""){
document.getElementById("show").innerHTML = "";
document.getElementById("show").innerHTML = AjaxObj.responseText;
}
}else{
alert("Exception.");
}
}else{
document.getElementById("show").innerHTML="Loading......";
}
}
a.php
代码如下:
<?php
header("Content-Type:text/html; charset=utf-8");
$name = $_POST['name'];
echo $name;
?>
全用utf-8编写存储,但死活就是不行,总说有问题,总出来有乱码,一天下来,脑袋晕乎乎滴,中午时候胳膊上绑了3kg沙袋,挥羽毛球拍挥了200,肌肉有点胀的感觉了,嗯,说明有锻炼效果了,过些天等发了薪水再去买一支练习拍,我常用的at700大约90g左右,练习拍在160g左右,应该比较有练习效果吧,不过右胳膊眼见着要比左胳膊粗了,貌似还需要一个大点的杠铃,把左胳膊也练一下才好
吃完晚饭,一怒之下,就把这三文件传一php的服务器上,一试,完全正常,没有乱码,我,我不说了,看来是resin的原因,呆会再找找,看一下Quercus有没最新的版本,是不是能支持的更好一些。