//Gets the browser specific XmlHttpRequest Object function getXmlHttpRequestObject() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); //Not IE } else if(window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); //IE } else { //Display your error message here. //and inform the user they might want to upgrade //their browser. return false; } } function ajax_request(url, callback_function) { //Get our browser specific XmlHttpRequest object. var receiveReq = getXmlHttpRequestObject(); // If the browser doesn't support Ajax, just give up if (receiveReq == false) return false; //If our XmlHttpRequest object is not in the middle of a request, start the new asyncronous call. if (receiveReq.readyState == 4 || receiveReq.readyState == 0) { //Setup the connection as a GET call to url //True explicity sets the request to asyncronous (default). receiveReq.open("GET", url, true); //Set the function that will be called when the XmlHttpRequest objects state changes. receiveReq.onreadystatechange = callback_function; //Make the actual request. receiveReq.send(null); } } function track_link(id) { if (id != 0) { ajax_request('/external_link.html?track=1&id=' + id, null); } return true; }