All pastes #441857 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-04-15 21:54 UTC
rendered paste body
window.onload = initAll;

var xhr = false;

function initAll(){

	getNavigation("?page=6");

}

function getRecords(pars){

	makeRequestGET("../cgi-bin/get_content.php", pars);

	return false;

}

function getNavigation(pars){

	makeRequestGET("../cgi-bin/get_navigation.php", pars);

	return false;

}

function makeRequestGET(url, params){

	if(window.XMLHttpRequest){

		xhr = new XMLHttpRequest();

	}

	else {

		try {

            xhr = new ActiveXObject("Msxml2.XMLHTTP");

        } catch (e) {

            try {

               xhr = new ActiveXObject("Microsoft.XMLHTTP");

            } catch (e) {}

        }

	}

	

	if(xhr){

		xhr.onreadystatechange = showContents;		

		xhr.open('GET', url+params, true);

		xhr.send(null);

		

	}

	else{

		document.getElementById("ulNav").innerHTML = "Sorry Couldnt make the HTTP request reqired by ajax";

	}

}

function showContents(){

	if(xhr.readyState == 4){

		if(xhr.status == 200){			

			if(/*xhr.responseXML && xhr.responseXML.contentType == "text/xml"*/true) {

				//var _xml = xhr.responseXML.getElementsByTagName("NAV")[0];

				//var _crumbs = _xml.getElementsByTagName("crumb");

				document.getElementById("ulNav").innerHTML = xhr.responseXML;// xhr.responseXML is null

				document.getElementById("ulNav").innerHTML = xhr.responseText;//this gives me the XML text ??? im confused a bit.

			}

			else{ 

				var outMsg = "Not Successfull! Status: "+ xhr.status +" Status Response: "+xhr.statusText+": Object Type:"+xhr+" "+xhr.responseText;

				document.getElementById("ulNav").innerHTML = outMsg;

			}	

		}

		//else{

		//	var outMsg = "There was a problem with the request " + xhr.status;

		//	document.getElementById("ulNav").innerHTML = outMsg;

		//}

		

	//}

	}

}

function blurDisplay(){

	document.getElementById("ulNav").innerHTML = "";//Clearing Mozilla First

	document.getElementById("ulNav").replaceNode(document.createTextNode(""));//Clearing IE

}