function createRequestObject(){ var xmlhttp = null; try { xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert('Sorry, but your browser doesn\'t support XMLHttpRequest.'); }; return xmlhttp; }; var http = createRequestObject(); function refreshImg1(){ var url = '/content/apps/captcha-refresh.php?grid=1&from=contact_us'; doRefresh1(url, displayImg1); }; function doRefresh1(url, callback) { http.open('POST', url, true); http.onreadystatechange = displayImg1; http.send(null); }; function displayImg1() { if(http.readyState == 4) { var showimage = http.responseText; document.getElementById('captchaImage').innerHTML = showimage; }; };