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;
}
}
}
ajax默认提交方式是get,首先看一下get、post的区别
1、 get是把参数数据队列加到提交表单的ACTION属性所指的URL中,值和表单内各个字段一一对应,在URL中可以看到。post是通过HTTP post机制,将表单内各个字段与其内容放置在HTML HEADER内一起传送到ACTION属性所指的URL地址。用户看不到这个过程。
2、 对于get方式,服务器端用Request.QueryString获取变量的值,对于post方式,服务器端用Request.Form获取提交的数据。两种方式的参数都可以用Request来获得。
3、get传送的数据量较小,不能大于2KB。post传送的数据量较大,一般被默认为不受限制。但理论上,因服务器的不同而异.
4、get安全性非常低,post安全性较高。
5、