Ruby Forum Captchator > ajax and captcha Permission Denied

Posted by Mark Babcock (markb)
on 26.06.2008 22:53
I keep getting a permission Denied and I'm not sure why.  Any able to
help with this?


<form name="myform">
<table>
    <tr>
           <td colspan="2"><img
src="http://captchator.com/captcha/image/123456"></td>
           <td><input type="button" value="reload captcha" alt="unable
to read captcha?"/></td>
    </tr>
    <tr>
           <td colspan="3"><input type="text" name="captchaValue"/></td>
    </tr>

</table>
</form>
<script language="JavaScript">
     var url = 'http://captchator.com/captcha/check_answer/123456/';
     var captchaOK = 2;  // 2 - not yet checked, 1 - correct, 0 - failed
     function getHTTPObject() {
          if(navigator.appName == "Microsoft Internet Explorer") {
              req = new ActiveXObject("Microsoft.XMLHTTP");
          } else {
              req = new XMLHttpRequest();
          }

         return req;

     }

      var http = getHTTPObject(); // We create the HTTP Object

      function handleHttpResponse() {
           if (http.readyState == 4) {
                 captchaOK = http.responseText;
                if(captchaOK != 1) {
                     alert('The entered code was not correct. Please try
again');
                     return false;
                }
              alert("Captcha okie dokie");
           }

      }

      function validateCaptcha() {

           var captchaValue = document.myform.captchaValue.value;
           var urlValidation = url + captchaValue;
alert(" ? " + urlValidation);
           http.open("GET", urlValidation);
alert("xx");
           http.onreadystatechange = handleHttpResponse;
alert("YY");
http.send(null);
      }
</script>
Posted by Jim Tobin (jtoly)
on 27.06.2008 05:19
Mark Babcock wrote:
> I keep getting a permission Denied and I'm not sure why.  Any able to
> help with this?

I just copied your code, created a new Rails project and set this code 
to be the index.html.erb file.

It "worked" fine for me, in so far as the captcha image loads, the 
button to reload the image is there and functions, and the text field 
accepts user input.

So while I don't see how your code was going to return a valid/not-valid 
response code (like I say I just pasted it in and haven't scrutinized 
it! :-), I don't get a Permission Denied problem.

Can you be more specific on when/where/how the error comes up?