var inProgress = false; var response = ""; function AJAXInteraction( url, callbackMethod, xmlID, htmlID ) { var req = getXmlHttpObject(); req.onreadystatechange = processRequest; function getXmlHttpObject() { var xmlHttp = null; try { // Firefox, Opera 8.0+, Safari xmlHttp = new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } } if( xmlHttp == null ) { alert ( "Your browser does not support AJAX!" ); } return xmlHttp; } // If the server has served the request, it should fire of the call back method function processRequest() { // Indicates the state or status of a request, The response is complete if( req.readyState == 4 ) { // Indicates the apparent success of the code, if 200 no errors if( req.status == 200 ) { if( callbackMethod ) { // Callback method callbackMethod( req, xmlID, htmlID ); // --- edited //alert( "success" ); inProgress = false; } } else { alert( "Error orccurred = " + req.statusText ); inProgress = false; } } else // Indicates that the request is still being handled { //alert( "in progress" ); inProgress = true; } } this.doGet = function() { req.open( "GET", url, true ); req.send( null ); } this.doPost = function( body ) { req.open( "POST", url, true ); req.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" ); req.send( body ); } } function loadRequest( url, callbackMethod, xmlID, htmlID ) { var ai = null; //var ai = new AJAXInteraction( url, callbackMethod, xmlID, htmlID ); if( !inProgress ) // Not in progress { ai = new AJAXInteraction( url, callbackMethod, xmlID, htmlID ); //ai.doGet(); ai.doPost("var=1"); } else { var shouldWait = wait( inProgress ); if( shouldWait ) { ai = new AJAXInteraction( url, callbackMethod, xmlID, htmlID ); //ai.doGet(); ai.doPost("var=1"); } } } function wait( inProgress ) { if( inProgress ) { //alert( "in progress" ); setTimeout( "wait( inProgress )", 5 ); return true; } else { return false; } } function writeHTML( req, xmlID, htmlID ) { document.getElementById( htmlID ).innerHTML = req.responseText; } function alertMsg( req, xmlID, htmlID ) { alert( req.responseText ); } function generateCombobox( req, xmlID, htmlID ) { var xmlDoc = req.responseXML.documentElement; //alert(req.responseText); //alert(req.responseXML); //document.getElementById('showMobileModels').innerHTML = req.responseText var groups = req.responseXML.getElementsByTagName( xmlID ); // option document.getElementById( htmlID ).options.length = 0; document.getElementById( htmlID ).options[0] = new Option ( "Vælg", 0 ); for( i=0; i