POST

<input type ="button"  value ="OK" onclick="btn('text')" />
       <br />
       <input type ="text"  id="text"/>

----------------------------------------------------------------

var xmlhttp;
function loadXMLDoc() {
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }
    else {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
}

function Ajax() {
    loadXMLDoc();
    xmlhttp.onreadystatechange = star;
    xmlhttp.open("POST", "Default.aspx",true);
    xmlhttp.setRequestHeader("Content-Type ", " application/x-www-form-urlencoded ");
    xmlhttp.send(); 

}

function star() {
    if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
            document.getElementById("DIV1").innerHTML= xmlhttp.responseText;
        }
        else {
            document.getElementById("DIV1").innerHTML = "Ajax信息返回错误!";
        }
    }
}


function btn(id) {
 alert(document.getElementById(id).value);
}

posted @ 2011-05-26 10:03  Silence-01  阅读(179)  评论(0编辑  收藏  举报