I currently call a Perl script from my website like this to produce a Captcha image like this:
<script language="JavaScript1.2" type="text/javascript" src="http://www.MyUrl/cgi-bin/Captcha-Image.pl"></script>
And I return Captcha Image to the web page like this:
<script language="JavaScript" type="text/javascript">
<!--
document.write (CAPTCHA);
//-->
</script>
This works fine but the issue I'm having is if the user clicks back the Captcha image does not refresh and needs to do so, as after it is submitted it is no longer valid.
So I'm trying to use this:
<input type="hidden" id="refreshed" value="no"/>
<script type="text/javascript">
onload = function () {
var e = document.getElementById("refreshed");
if (e.value == "no") e.value = "yes";
else { e.value = "no"; location.reload(); }
}
</script>
But instead of refreshing the page I would like to just recall the Perl script Im already using the "Cache-Control: no-cache tag" "http://www.MyUrl/cgi-bin/Captcha-Image.pl" to print a new image I tried this with no luck:
onload = function () {
var e = document.getElementById("refreshed");
if (e.value == "no") e.value = "yes";
else { e.value = "no"; location.reload('http://www.MyUrl/cgi-bin/Captcha-Image.pl'); }
}