Ajax提交方式post跟get修改,在线等!
下面是Ajax的一个get的提交过程,修改成post提交functionfunphp100(){varu=document.myform.users.value;if(u...
下面是Ajax的一个get的提交过程,修改成post提交function funphp100(){
var u = document.myform.users.value;
if (u==""){
var class1=document.getElementById("class1");
class1.innerHTML="* please write names";
return false;
}
else{
S_xmlhttprequest();
xmlHttp.open("GET","insert.php?users="+u,true);
xmlHttp.onreadystatechange = byphp;
xmlHttp.send(null);}}
function byphp(){
if (xmlHttp.readyState == 4){
if(xmlHttp.status==200){
document.getElementById("class1").innerHTML = xmlHttp.responseText;
}
}
} 展开
var u = document.myform.users.value;
if (u==""){
var class1=document.getElementById("class1");
class1.innerHTML="* please write names";
return false;
}
else{
S_xmlhttprequest();
xmlHttp.open("GET","insert.php?users="+u,true);
xmlHttp.onreadystatechange = byphp;
xmlHttp.send(null);}}
function byphp(){
if (xmlHttp.readyState == 4){
if(xmlHttp.status==200){
document.getElementById("class1").innerHTML = xmlHttp.responseText;
}
}
} 展开
2013-11-15
展开全部
function funphp100(){
var u = document.myform.users.value;
if (u==""){
var class1=document.getElementById("class1");
class1.innerHTML="* please write names";
return false;
}
else{
S_xmlhttprequest();
xmlHttp.open("POST","insert.php,true);
xmlHttp.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xmlHttp.onreadystatechange = byphp;
xmlHttp.send("users="+u);}
}
function byphp(){
if (xmlHttp.readyState == 4){
if(xmlHttp.status==200){
document.getElementById("class1").innerHTML = xmlHttp.responseText;
}
}
}
var u = document.myform.users.value;
if (u==""){
var class1=document.getElementById("class1");
class1.innerHTML="* please write names";
return false;
}
else{
S_xmlhttprequest();
xmlHttp.open("POST","insert.php,true);
xmlHttp.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xmlHttp.onreadystatechange = byphp;
xmlHttp.send("users="+u);}
}
function byphp(){
if (xmlHttp.readyState == 4){
if(xmlHttp.status==200){
document.getElementById("class1").innerHTML = xmlHttp.responseText;
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询