Jump to content
php.lv forumi

Nestrādā uz IE7 Cross-browser XMLHttpRequest object


Sasa

Recommended Posts

Uz IE6 viss strādā, bet uz IE7 nevar ieladāt nolasīto.

 

<script type=text/javascript>
//melamina mala korpusam
//create the Cross-browser XMLHttpRequest object
function getFile11(pURL11,pFunc11) {
if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc 
	xmlhttp11=new XMLHttpRequest();
	eval('xmlhttp.onreadystatechange1='+pFunc11+';');
	xmlhttp11.open("GET", pURL11, true); // leave true for Gecko
	xmlhttp11.send(null);
} else if (window.ActiveXObject) { //IE 
	xmlhttp11=new ActiveXObject('MSXML2.XMLHTTP.3.0'); //MSXML2.XMLHTTP.3.0  Microsoft.XMLHTTP
	if (xmlhttp11) {
		eval('xmlhttp11.onreadystatechange='+pFunc11+';');
		xmlhttp11.open('GET', pURL11, false);
		xmlhttp11.send();
	}
}

}

function makeList11() {
if (xmlhttp11.readyState==4) { 
	if (xmlhttp11.status==200) { 
		var tmpArr11=xmlhttp11.responseText.split('\n');
		var out11='<select class="listbox"  id=selekts11 name="states11" size="1" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; WIDTH: 5.2cm; BORDER-BOTTOM: 0px">';
		var tmp11;
		var val11;
		var txt11;
		var all11 = {};
		for (var idx1=0;idx1<tmpArr11.length;idx1++) {
			 var tmp11=tmpArr11[idx1].split(',');
			 var kod11 = tmp11[0].replace('"','').replace('"','');
			 var txt11 = tmp11[2].replace('"','').replace('"','');
			 var val11 = tmp11[3].replace('"','').replace('"','') +' , '+ txt11+ ' , '+ kod11;				 

			all11[val11] = txt11;
		}

		for (var val11 in all11)
		{
			out11 += '<option value="'+val11+'">'+all11[val11]+'</option>';
		}
		document.getElementById('theExample11').innerHTML=out11;

	}
}

}
</SCRIPT>

Link to comment
Share on other sites

iekš googles atradu kaut ko

f (window.XMLHttpRequest){

	  // If IE7, Mozilla, Safari, etc: Use native object
	  var xmlHttp = new XMLHttpRequest()

}
else
{
if (window.ActiveXObject){

	  // ...otherwise, use the ActiveX control for IE5.x and IE6
	  var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	  }

}

 

bet man jau arī tā ir

 

if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc
	xmlhttp11=new XMLHttpRequest();
	eval('xmlhttp.onreadystatechange1='+pFunc11+';');
	xmlhttp11.open("GET", pURL11, true); // leave true for Gecko
	xmlhttp11.send(null);
}

Link to comment
Share on other sites

Tavi jautājumi, Sasa, ir pavisam dīvaini...

Meklē nevis iekš gūgles, bet gan iekš sava koda. Debugerī palaid un apskaties pa soļiem kur kautkas nestrādā.

 

Un nevajag divas vienādas koda daļas rakstīt.

		eval('xmlhttp.onreadystatechange1='+pFunc11+';');
	xmlhttp11.open("GET", pURL11, true);
	xmlhttp11.send(null);

ir kopējs abiem - iznes to ārpus visiem if'iem.

Link to comment
Share on other sites

×
×
  • Create New...