日期:2014-05-16 浏览次数:20619 次
<script> var xmlHttp; function createXmlRequest() { if(window.ActiveXObject){ var xmlHttps=["MSXML2.XMLHttp.5.0","MSXML2.XMLHttp4.0", "MSXML2.XMLHttp3.0","MSXML2.XMLHttp","Microsoft.XMLHTTP"]; try{ for(var i=0;i<xmlHttps.length;i++){ var xmlHttp=new ActiveXObject(xmlHttps[i]); return xmlHttp; } } catch (error){ } } else{ var xmlHttp=new XMLHttpRequest(); return xmlHttp; } throw new Error("失败"); } function insert(){ xmlHttp=createXmlRequest(); xmlHttp.onreadystatechange=handleStateChange; xmlHttp.open("GET","Handler.ashx?user="+document.getElementById("txtUser").value+"",true); xmlHttp.send(null); } function handleStateChange(){ if(xmlHttp.readyState==4){ if(xmlHttp.responseText=="Y")alert("success"); else alert("faile"); } } </script> <input type="text" id="txtUser" /> <input type="button" id="d" onclick="test();" />