1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
   |  
	<html>
	<head>
	<title>Get XML test page</title>
	<style>
	//some style declarations left out for brevity
	</style>
 
	<script type="text/javascript">
	var xmlhttp=null;
	var strOutput ="";
	var toLoad = "http://my_server.fr/categories_b.jsp;jsessionid=OC0MVZ?langue=fr%5FFR&buy=1&uniqueid=OC0MVZ";
 
 
	function sendRequest(){
	if (window.XMLHttpRequest){
	xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject){
	try {
	xmlhttp= new ActiveXObject("Msxml2.XMLHTTP");
	} catch(e) {
	try {
	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	} catch(e) {
	xmlhttp = false;
	}
	}
	}
	if (xmlhttp){
	xmlhttp.onreadystatechange=onReadyState;
	// xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');        -> POST
	xmlhttp.open("GET", toLoad, true);
	xmlhttp.setRequestHeader('Content-Type', 'text/xml'); 
	xmlhttp.send(null);
	}
	}
 
 
	function onReadyState(){
	if (xmlhttp.readyState==4){
	if (xmlhttp.status==200) {
 
		var xmlDoc = xmlhttp.responseXML;
		var rep_list = xmlDoc.getElementsByTagName("category");
		for (var i=0; i < rep_list.length; i++) {
		strOutput += rep_list[i].firstChild.nodeValue + "<br/>";
		}
		document.getElementById('divContent').innerHTML=strOutput;
	}
	}
	}
 
 
	function doReplace(strXML) {
	var strOut = "";
	var strL = /</g;
	var strG = />/g;
	var strAmp = /&/g;
	strOut = strXML;
	strOut = strOut.replace(strAmp, "&");
	strOut = strOut.replace(strL, "<");
	strOut = strOut.replace(strG, ">");
	return strOut;
	}
 
 
	</script>
	</head>
	<body onload="sendRequest()">
	<div class="divStyle" id="divContent" >Loading...</div>
	</body>
	</html> | 
Partager