Source of AjaxLibrary.js

var Ajax = new Object();
 

Top

Ajax.getContentFromURI = function(sFromUrl, oTargetElement, callback, skipCache) {
    try{
        oTargetElement.innerHTML = "... loading ...";
        xAddClass(oTargetElement,"loading");
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.open("GET", sFromUrl, true);
        
        function ajax_dhtml_loadHandler() {
            if (xmlhttp.readyState == 4) {
                Ajax.updateContentFromNode(xmlhttp.responseXML, oTargetElement, callback);
            };
        };
        xmlhttp.onreadystatechange = ajax_dhtml_loadHandler;
        if (skipCache) {
             var oldage = "Sat, 1 Jan 2000 00:00:00 GMT";
             xmlhttp.setRequestHeader("If-Modified-Since", oldage);
        };
        xmlhttp.setRequestHeader("Accept","x-ajax");
        xmlhttp.send("");
    }
    catch(e){
        oTargetElement.innerHTML = "load failed: "+e;
        throw e;
    };
};
 
Ajax.updateContentFromNode = function(oNode, oTargetElement, callback) {
    try {
        Sarissa.clearChildNodes(oTargetElement);
        xRemoveClass(oTargetElement,"loading");
        // check for parsing errors
        var ownerDoc = oNode.nodeType == Node.DOCUMENT_NODE?oNode:oNode.ownerDocument;
        if(ownerDoc.parseError && ownerDoc.parseError != 0) {
            var pre = document.createElement("pre");
            pre.appendChild(document.createTextNode(Sarissa.getParseErrorText(ownerDoc)));
            oTargetElement.appendChild(pre);
        }
        else {
            callback(oNode,oTargetElement);
        };
    }
    catch(e) {
        oTargetElement.innerHTML = "update failed: "+e;
        xAddClass(oTargetElement,"error");
    }
};
 
Ajax.copyChildren = function(f,t) {
  if (!f || !t) return;
 
  var s = new XMLSerializer();
  var ht = "";
 
  for (var i = 0; i < f.childNodes.length; i++) { ht += s.serializeToString(f.childNodes[i]); }
  t.innerHTML = ht;
}