function b1(){
var post="user=sheneyan&pw=1234";
xml.open("POST","testAjaxPost.php",false);
xml.setrequestheader("content-length",post.length);
xml.setrequestheader("content-type","application/x-www-form-urlencoded");
xml.send(post);
alert(xml.responseText);
}
function b2(){
var post="12qwrf";
xml.open("POST","testAjaxPost.php?data",false);
xml.send(post);
alert(xml.responseText);
}
function b3(){
var get="user=sheneyan&pw=1234";
xml.open("GET","testAjaxPost.php?"+get,false);
xml.send();
alert(xml.responseText);
}
function b4(){
var get="user=sheneyan&pw=1234";
var post="_user=帅青蛙&_pw=4321";
xml.open("POST","testAjaxPost.php?"+get,false);
xml.setrequestheader("content-length",post.length);
xml.setrequestheader("content-type","application/x-www-form-urlencoded");
xml.send(post);
alert(xml.responseText);
}
testAjaxPost.php的源代码:
<?
if (!isset($_GET["data"])){
$c=count($_POST);
echo "post参数有".$c."个\n";
if ($c>0){
echo "分别是:\n\n";
foreach ($_POST as $k=>$v){
echo urldecode($k)."=>".urldecode($v)."\n";
}
}
$c=count($_GET);
echo "--------------\nget参数有".$c."个\n";
if ($c>0){
echo "分别是:\n\n";
foreach ($_GET as $k=>$v){
echo urldecode($k)."=>".urldecode($v)."\n";
}
}
}
else{
echo($HTTP_RAW_POST_DATA);
}
?>
posted on 2006-07-12 16:12
汪杰 阅读(323)
评论(0) 编辑 收藏 引用 所属分类:
ajax