2013-03-01 3 views
2

나는 이클립스 IDE와 그 잘 작동하는 나의 라이브러리에서 simplecaptcha 1.2.1 jar 파일을 가지고있다. captcha를 새로 고칠 수있는 옵션이 없었기 때문에 다음 코드를 추가했지만 작동하지 않았습니다. 간단한 captcha를 새로 고치는 방법

function refreshCaptcha() 
{ 
    var xmlhttp; 
    if (window.XMLHttpRequest) 
     { 
     xmlhttp=new XMLHttpRequest(); 
     } 
    else 
     { 
     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
     } 
    xmlhttp.onreadystatechange=function() 
     { 
     if (xmlhttp.readyState==4) 
     { 
     if(xmlhttp.status==200) 
      { 
      alert(xmlhttp.responseText);     
     document.getElementById("captcha").innerHTML=xmlhttp.responseText; 
     } 
     } 
     } 
    xmlhttp.open("GET","captchaImg",true); 
    xmlhttp.send(); 
} 

내 HTML 부분은 추가

 <img src="captchaImg" id="captcha"/> 
     <img src="resources/images/refresh.jpeg" onclick="refreshCaptcha()"/> 

점점 경고 메신저에서 respone 어떤이 --PNGIHDR23j

"captchaImg"와 같은 일부입니다 web-xml의 서블릿 매핑에서 URL 패턴으로. 누군가 captcha를 상쾌하게하는 방법을 도와 줄 수 있어요.

+0

에게'img'을 추가 한 아약스 호출의 필요가없는 내부 HTML이 없습니다. – Amberlamps

+0

그때 제발 내가 할아버지, 그에게 의식을 얻으려고 말하십시오 – amit

+0

일부 서버 측 기술을 사용하고 있습니까? PHP, Python 등과 같은? – Passerby

답변

1

난 그냥이 코드

onclick="document.getElementById('captcha').src='captchaImg?'+ 
    (new Date().getTime());" this thing is most important one ?' 
      +(new Date().getTime());