如何使用 POST 方法发送以下请求?
lun = document.getElementById("lun").value;
lp = document.getElementById("lp").value;
url = "lun="+lun+"&lp="+lp;
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById("login").innerHTML=xmlhttp.responseText;
}
else{
document.getElementById("login").innerHTML="Loading";
}
}
xmlhttp.open("GET",'login.php?'+url,true);
xmlhttp.send();
最佳答案
要使用的 HTTP 方法,例如“GET”、“POST”、“PUT”、“DELETE”等。对于非 HTTP(S) URL 将被忽略。
xmlhttp.open("POST",'login.php',true);
xmlhttp.send(url);
引用号:https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest
关于javascript - 使用 AJAX 发送用户 POST 输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20995648/