Copy code code as follows:
<script language= "JavaScript" >
Function cl ()
{
var xmlhttp;
if (window. XMLHttpRequest)
{
xmlhttp=new xmlhttprequest ();
}
Else
{
xmlhttp=new activexobject ("Microsoft.XMLHTTP");
}
Xmlhttp.open ("POST", "ajax2.html", true);
Xmlhttp.setrequestheader ("Content-type", "application/x-www-form-urlencoded");
//jquery Yui sends an HTTP request header message with Http_x_requested_with by default, so you can determine if Ajax is requested by determining whether the request header contains this property
Xmlhttp.setrequestheader (' Http_x_requested_with ', ' http_x_requested_with ');
Xmlhttp.send ();
Xmlhttp.onreadystatechange=function ()
{
if (xmlhttp.readystate==4 && xmlhttp.status==200) br>{
Alert (xmlhttp.responsetext);
}
{
}
</script>
<body>
<input type= "button" id= "BT" Name= "BT" value= "OK" oncLick= "cl ();"/>
</body>