// var strSiteURL = "http://localhost/"; var strSiteURL = "https://www.drinkmixguide.com/"; function default_handle(callback_element, strText) { document.getElementById(callback_element).innerHTML = strText; } function defaultPopupHandle(strText) { displayPopup(objPopup, strText, false, 250); } function defaultPopupHandleCentered(strText) { displayPopup(objPopup, strText, true, 250); } // Places strHTML into callback_element's innerHTML // Runs JavaScript specified by strJS function updateElementRunJS(callback_element, strText) { var objReturn = eval('(' + strText + ')'); default_handle(callback_element,objReturn.strHTML); // Place strHTML eval(objReturn.strJS); // Run strJS } function setAlertMessage(strResponse) { if(strResponse) { var objRecords = eval('(' + strResponse + ')'); showHoverAlert(objRecords.strAlertMessage, objRecords.strSuccErr, 5); } } /**************************** Ajax Http Request Function ********************************/ /* Desc: The AjaxRequest operates across all popular browsers and works as follows: The parameters of the function are 'URL', 'Element ID' where 'Return Text' will be returned, Function that will be called with the 'Element ID' and 'Return Text' as parameters and XML boolean. 1st Param: - If you choose to just call a request on the server without having a return, you may only pass the first URL parameter. The file in the URL will be executed on the server with NO-return. 2nd Param: - When you call the function with two parameters, the second should be the ID of the element where the 'echo' of the URL file will be returned. 3rd Param: - When you call the function with three parameters, your third parameter will be the JavaScript function which will be called when the request has been executed. Instead of returning the 'echo' from the URL directly to the innerHTML of 'Element ID', it will call the function [callback_function]( [callback_element], 'Return Text' ) This gives more versitility to what you want to do with the return. You can tokenize it with JavaScript, and perform various functions on the client side. A function call with three parameters should be used when a LOT OF DATA is returned in the 'Return Text'. It will decrease the amount of data that is sent between client and server and improve overall performance. However, if the 'Return Text' is small, this is not necessary. 4th Param: - The forth parameter should be used when XML text is returned in the 'Return Text'. It enhances performance and further standardises return. This parameter should only be used if strictly XML is to be returned. */ function AjaxRequest(url, callback_element, callback_function, return_xml ) { var http_request = false; if (window.XMLHttpRequest) { // Mozilla, Fire Fox, Safari, IE7 .. http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { // Internet Explorer 6 try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Unfortunately you browser doesn\'t support this feature.'); return false; } http_request.onreadystatechange = function() { if (http_request.readyState == 4) { if (http_request.status == 200) { var strResponseEnding = 'Text'; if (return_xml) { strResponseEnding = 'XML'; } if (callback_function) { if(callback_element == null) { callback_function(eval('http_request.response'+strResponseEnding)); } else { var strTemp = eval('http_request.response'+strResponseEnding); if(typeof callback_function == 'string') { // If function is passed as a string //alert(callback_function); eval(callback_function+'("'+callback_element+'",strTemp);'); } else { // If function is passed as a function callback_function(callback_element,strTemp); } } } } else { alert('There was a problem with the request.(Code: ' + http_request.status + ')'); } } } http_request.open('GET', url, true); http_request.send(null); }