当前位置: 代码迷 >> Ajax >> post 与get的区别
  详细解决方案

post 与get的区别

热度:758   发布时间:2012-02-02 23:57:14.0
post 与get的区别 - Web 开发 / Ajax
adjax.js
var xmlHttp;
function S_xmlhttprequest()
{
if(window.ActiveXobject)
{
xmlHttp=new ActiveXObject('Microsoft.XMLHttp');


}
else 
{
xmlHttp=new XMLHttpRequest();

}
}

function funphp100(f)

{
var f=document.myform.username.value;
alert(f);
S_xmlhttprequest(f);
xmlHttp.open("GET","login.php?id="+f ,true);
xmlHttp.onreadystatechange=byphp;
xmlHttp.send(null);

}
function byphp()
{
if(xmlHttp.readyState==1){
document.getElementById('php100').innerHTML="<img src=loading.jpg>";


}
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
var byphp100=xmlHttp.responseText;
document.getElementById('php100').innerHTML=byphp100;

}

}

}


index.php


<?php


?>

<script type="text/javascript" src="ajax.js"></script>

<form name="myform" action="" method="post">
邮 &nbsp&nbsp 箱:<input type="text" name="username" value="" size="40" maxlength="40"onblur="funphp100('PHP100')"/>
<div id="php100"></div><br/>
密 &nbsp&nbsp 码:<input type="password" name="password" value="" size="40" maxlength="40"><br/>
确认密码:<input type="password" name="password1" value="" size="40" maxlength="40"><br/>
验 证 码:<input type="text" name="yzm" value=""size="40" maxlength="40"><br/>
<img src="yzm.php">
<input type="submit" size="40" name="submit" value="submit"><br/>


</form>



login.php



<?php
if ($_GET['id'])
{
echo "hello";

}


?>


为什么换成post 就会报undefined id?


------解决方案--------------------
用$_POst['id']
  相关解决方案