function createXmlHttp() { var xmlHttp; try{ if( window.ActiveXObject ) { for( var i = 5; i > 0; i--) { try{ if( i == 2 ) { xmlHttp = new ActiveXObject('Microsoft.XMLHTTP'); }else{ //此处不知为何用4.0、5.0会出现乱码 //xmlHttp = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" ); xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } //这些方法为何不能用??? //xmlHttp.setRequestHeader("Content-Type","text/xml"); //xmlHttp.setRequestHeader("Content-Type","GBK"); break; } catch(e){ xmlHttp = false; } } }else if( window.XMLHttpRequest ){ xmlHttp = new XMLHttpRequest(); if (xmlHttp.overrideMimeType) { xmlHttp.overrideMimeType('text/xml'); } } }catch(e){ xmlHttp = false; } return xmlHttp; }