日期:2014-05-16 浏览次数:20647 次
<script language="javascript" type="text/javascript"> var xmlHttp; var requestType = ""; function createXMLHttpRequest() {x if (ActiveXObject)a { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } else if (XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); } } function showDB(returestedList) { requestType = returestedList; createXMLHttpRequest(); xmlHttp } </script> </head> <body> <form id="form1" runat="server"> <div> <input id="btnOne" type="button" value="只显示第一页" onclick="return showDB('one')" /></div> </form> <p> <input id="btnAll" type="button" value="全部显示" onclick="return showDB('two')" /></p> </body>
//if(ActiveXObject) //=========>> if(window.ActiveXObject)
------解决方案--------------------
var xmlHttp; function createXmlHttpRequest() { if(window.XMLHttpRequest) { xmlHttp=new XMLHttpRequest(); if(xmlHttp.overrideMimeType) { xmlHttp.overrideMimeType("text/xml"); } } else if(window.ActiveXObject) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } if(!xmlHttp) { window.alert("你的浏览器不支持创建XMLhttpRequest对象"); } return xmlHttp; }