// // global xmlHttp object // var nthClickXMLHttp; /* * Name: * showHint * * Description: * this function calls server side script * * Preconditions/Input: * * Postconditions/Output: * gives the response text from the server side script * * Stored Procedures: * None * * Log: * Dipak A.Basantani 11/02/2007 * Updates * Surendra Shukla 05/01/2008 * - Time added to url to generate unique url so that it can work properly in IE * */ function showHint(paramArray) { // // make global // displayId = paramArray['id']; document.getElementById(displayId).innerHTML=""; // // get the xmlHttp object // nthClickXMLHttp=GetXmlHttpObject() // // check if it is not null // if (nthClickXMLHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url= paramArray['url']; var firstParam = true; // count for checking first parameter or not for(x in paramArray) { if(x == 'id' || x == 'url') { continue; } if(firstParam) { url= url+"?"+x+"="+paramArray[x] ; firstParam = false; } else { url= url+"&"+x+"="+paramArray[x] ; } } var d = new Date(); url = url +"&" + d.getTime(); nthClickXMLHttp.onreadystatechange=redirectUrltoNthUrl; nthClickXMLHttp.open("GET",url,true); nthClickXMLHttp.send(null); } /* * Name: * showHint * * Description: * check for the ready state and from the response text redirect to * the success or failure link * * Preconditions/Input: * * Postconditions/Output: * will redirect to the success or failure link * * Stored Procedures: * None * * Log: * Dipak A.Basantani 11/02/2007 */ function redirectUrltoNthUrl() { var tmp; var newWindowOption; if (nthClickXMLHttp.readyState==4) { tmp = 'returnData='+ nthClickXMLHttp.responseText; eval(tmp); newWindowOption = returnData.openInNewWindow; // // check if open in new window is true // if(newWindowOption) { window.open(returnData.url); } else { location.href = returnData.url; }// end if - open in new window is true } } /* * Name: * GetXmlHttpObject * * Description: * create xmlhttpObject to call the server side script. * * Preconditions/Input: * * Postconditions/Output: * return xmlHttpObject * * Stored Procedures: * None * * Log: * Dipak A.Basantani 11/02/2007 */ 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"); } } return xmlHttp; } /* * Name: * GetXmlHttpObject * * Description: * collect the function parameters and make a array to pass into the * showHint function to call server side script * * Preconditions/Input: * call the function showHint to call the server side script * * Postconditions/Output: * * * Stored Procedures: * None * * Log: * Dipak A.Basantani 11/02/2007 * Updates * Surendra Shukla 05/01/2008 * - Passing only stnBoxId to ajax file * */ function checkNthClick(liteLinkId, stnBoxId) { var parameterArray = new Array(); parameterArray['id'] = 'nthurldiv'+liteLinkId; parameterArray['url'] = '/check_nth_click.php'; parameterArray['functionName'] = 'redirectUrltoNthUrl'; parameterArray['stnBoxId'] = stnBoxId; showHint(parameterArray); }