// gets the base path of the ajax call, corrected for protocol. function ajaxBasePath() { var base_path = "http://www1.subimo.com/cav4/app/hcboexp/ajax"; base_path = correctAddressProtocol(base_path); return base_path; } /* Used to work around a goofiness we've run into; makes sure that if the protocol should be https, then it stays https, so that the Ajax call doesn't fail on XMLHttpRequest.open. */ function correctAddressProtocol(suspect_url) { //alert(suspect_url.substring(7)); var protocol_target = parse_protocol(suspect_url); var protocol_actual = parse_protocol("" + window.location); if (protocol_target != protocol_actual) { return protocol_actual + suspect_url.substring(protocol_target.length); } return suspect_url; } // find the protocol (what's before the '//') function parse_protocol(url) { var protocol_ends = url.search("//") return url.substring(0,protocol_ends); } // the general server interaction method - uses Ajax to call the server with // the 'target' request... function callServer(target, handlerMethod) { req = getXMLHttpRequest(); // get the test document; will populate the headers as well:-) req.onreadystatechange = handlerMethod; req.open("GET", target, true); req.send(null); } // the XMLHttpRequest object referenced when the handleProcessing function is used... var req; // generic handling method; calls a page-specific javascript method when ready... function handleProcessing() { // jumping to the landing page and jumping back quickly has caused this to be // called with a noninitialized 'req' variable - this should fix the resulting error:-) if (req == undefined) { return; } if (req.readyState==4) { var doc_val = req.responseText; // this is defined once for each page that uses Ajax, to handle it's // special case(s) handleAjaxResults(doc_val); } } function emptyAjaxHandler() { } // IE and FF don't much like each other... function getXMLHttpRequest() { var xmlhttp; /*@cc_on @if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @else xmlhttp = false; @end @*/ if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; } } return xmlhttp; } // since the logout request does not use the handleProcessing() method, need to hold the // request object in another variable, to prevent the handling method being assigned a // non-empty method from either the landing page of planQuestions. var logout_ajax_requester; // sends a logout request to the server, then closes the current window (if opened by javascript, anyway) function logout() { // send Logout to clear server session var logout_call = ajaxBasePath() + "/logout"; logout_call = correctAddressProtocol(logout_call); var logout_req = getXMLHttpRequest(); // get the test document; will populate the headers as well:-) logout_req.onreadystatechange = emptyAjaxHandler; logout_req.open("GET", logout_call, true); logout_req.send(null); // conflicts with the global 'req' object used for the questions - // the questions may overwrite the empty handling method, causing a // stop error: callServer(logout_call, emptyAjaxHandler); }