xmlhttprequest生成方式
xmlhttp生成,最基本的ajax形式,记录一下;
这是post形式;
<script type="text/javascript">
var xmlhttp=false;
function flogin(){
if(window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
}else{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
if(xmlhttp)
{
var v1 = 'sss';
var v2 = 'sss';
//
xmlhttp.open("POST", "http://localhost:8080/fsss/ajaxLogin.action", true);
xmlhttp.onreadystatechange = fCallback;
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.send("username=" + v1 + "&password=" + v2);
}
}
function fCallback()
{
if(xmlhttp.readyState == 4)
{
if(xmlhttp.status == 200)
{
alert('ok');
}
}
}
flogin();
</script>当然不是比较成熟的形式,只是基本形式。