// global xmlhttprequest object var xmlHttp = false; var objectname; /** AJAX functions **/ var maincat; // constants var REQUEST_GET = 0; var REQEST_POST = 2; var REQUEST_HEAD = 1; var REQUEST_XML = 3; var merkewarensort; function getXMLRequester( ) { var xmlHttp = false; try { // Internet Explorer if( window.ActiveXObject ) { for( var i = 5; i; i-- ) { try { // loading of a newer version of msxml dll (msxml3 - msxml5) failed // use fallback solution // old style msxml version independent, deprecated if( i == 2 ) { xmlHttp = new ActiveXObject( "Microsoft.XMLHTTP" ); } // try to use the latest msxml dll else { xmlHttp = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" ); } break; } catch( excNotLoadable ) { xmlHttp = false; } } } // Mozilla, Opera und Safari else if( window.XMLHttpRequest ) { xmlHttp = new XMLHttpRequest(); } } // loading of xmlhttp object failed catch( excNotLoadable ) { xmlHttp = false; } return xmlHttp ; } function sendRequestSI( strSource, strData, intType, intID ) { if( !strData ) strData = ''; // default type (0 = GET, 1 = xml, 2 = POST ) if( isNaN( intType ) ) intType = 0; // GET // previous request not finished yet, abort it before sending a new request if( xmlHttp && xmlHttp.readyState ) { xmlHttp.abort( ); xmlHttp = false; } if( !xmlHttp ) { xmlHttp = getXMLRequester( ); if( !xmlHttp ) return; } // parse query string if( intType != 1 && ( strData && strData.substr( 0, 1 ) == '&' || strData.substr( 0, 1 ) == '?' ) ) strData = strData.substring( 1, strData.length ); // data to send using POST var dataReturn = strData ? strData : strSource; switch( intType ) { case 1: // xml strData = "xml=" + strData; case 2: // POST // open the connection xmlHttp.open( "POST", strSource, true ); xmlHttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' ); xmlHttp.setRequestHeader( 'Content-length', strData.length ); break; case 3: // HEAD // open the connection xmlHttp.open( "HEAD", strSource, true ); strData = null; break; default: // GET // open the connection var strDataFile = strSource + (strData ? '?' + strData : '' ); xmlHttp.open( "GET", strDataFile, true ); strData = null; } // set onload data event-handler xmlHttp.onreadystatechange = new Function( "", "processResponseSI(" + intID + ")" ); ; // send request to server xmlHttp.send( strData ); // param = POST data return dataReturn; } /** * process the response data from server * * @param intID, Integer, ID of this response */ function processResponseSI( intID ) { switch( xmlHttp.readyState ) { // uninitialized case 0: // loading case 1: // loaded case 2: // interactive case 3: break; // complete case 4: // check http status if( xmlHttp.status == 200 ) // success { processDataSI( xmlHttp, intID); } // loading not successfull, e.g. page not available else { if( window.handleAJAXError ) handleAJAXError( xmlHttp, intID ); else //alert("ERROR\n HTTP status = " + xmlHttp.status + "\n" + xmlHttp.statusText ) ; x=1; } } } /** End AJAX functions **/ /** real application functions **/ // process data from server function processDataSI( xmlHttp, intID ) { // process text data updateMenuSI( xmlHttp.responseText); } function getDataSI(hersteller,modell) { if (modell.length>1) { var jetzt = new Date(); var strURL = "//www.rezervnideli24.si/ajax386.php?cachekiller="+jetzt.getUTCMilliseconds()+"&hersteller="+hersteller+"&modell="+modell; sendRequestSI( strURL); } } function Mid(str, start, len) { // Make sure start and len are within proper bounds if (start < 0 || len < 0) return ""; var iEnd, iLen = String(str).length; if (start + len > iLen) iEnd = iLen; else iEnd = start + len; return String(str).substring(start,iEnd); } function InStr(strSearch, charSearchFor) { for (i=0; i < strSearch.length; i++) { if (charSearchFor == Mid(strSearch, i, 1)) { return i; } } return -1; } // process data from server, updates second select menu // data from server comes with this format: value=data&value=data... function updateMenuSI( strData) { if( strData ) { document.getElementById("resultareaSI").innerHTML=strData; } }