ajax post t提交纯 js 代码

function ajax_driv() ... {
varxmlhttp;
if(window.ActiveXObject)...{
/**//*不要删除以下注释,这部分不是注释*/
/**//*@cc_on@*/
/**//*@if(@_jscript_version>=5)
try{
xmlhttp=newActiveXObject("Msxml2.xmlhttp");
}catch(e){
try{
xmlhttp=newActiveXObject("Microsoft.xmlhttp");
}catch(e){
xmlhttp=false;
}
}
@end@
*/

}
else...{
xmlhttp
=newXMLHttpRequest();
}

if(!xmlhttp&&typeofXMLHttpRequest!='undefined')...{
xmlhttp
=newXMLHttpRequest();
}

returnxmlhttp;
}

function posthtm(url) ... {//isnullor1

//doc.innerHTML='<span><imgsrc="image/load.gif"/>Loading...</span>';
varxmlhttp=false;





varverbs="username=123";
xmlhttp
=ajax_driv();

xmlhttp.open(
"POST","/alldata.aspx",true);

xmlhttp.onreadystatechange
=function()...{
if(xmlhttp.readyState==4)...{
document.write(xmlhttp.responseText);
document.close();
}

}

xmlhttp.setRequestHeader(
"Content-Length",verbs.length);
xmlhttp.setRequestHeader(
"CONTENT-TYPE","application/x-www-form-urlencoded");

xmlhttp.send(verbs);

}
function ajax_driv(){
var xmlhttp;
if (window.ActiveXObject){
/* 不要删除以下注释,这部分不是注释 */
/* @cc_on@ */
/* @if(@_jscript_version>=5)
try{
xmlhttp=newActiveXObject("Msxml2.xmlhttp");
}catch(e){
try{
xmlhttp=newActiveXObject("Microsoft.xmlhttp");
}catch(e){
xmlhttp=false;
}
}
@end@
*/
}
else {
xmlhttp
= new XMLHttpRequest();
}
if ( ! xmlhttp && typeof XMLHttpRequest != ' undefined ' ){
xmlhttp
= new XMLHttpRequest();
}
return xmlhttp;
}
function posthtm(url){ // isnullor1

// doc.innerHTML='<span><imgsrc="image/load.gif"/>Loading...</span>';
var xmlhttp = false ;





var verbs = " username=123 " ;
xmlhttp
= ajax_driv();

xmlhttp.open(
" POST " , " /alldata.aspx " , true );

xmlhttp.onreadystatechange
= function (){
if (xmlhttp.readyState == 4 ){
document.write(xmlhttp.responseText);
document.close();
}
}
xmlhttp.setRequestHeader(
" Content-Length " ,verbs.length);
xmlhttp.setRequestHeader(
" CONTENT-TYPE " , " application/x-www-form-urlencoded " );

xmlhttp.send(verbs);

}

你可能感兴趣的:(Ajax,Microsoft)