Retrieving content from another page with broken javascript

I tried to do a client side check for captcha. To do this, I need to get an answer from the outside url. For this, I used the code below javascript.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
  function captcha_check()
  {
    var code = document.getElementById("captcha").value;
    alert(code);
    var url = "http://www.opencaptcha.com/validate.php?img='.$captcha_name.'.jpgx&ans="+code;
    alert(url);
    $.get(url,function(data,status){
      alert(data);
      if(data == "fail")
      {
        document.getElementById("captcha_error").style.display = "block";
        return false;
      }
      else
      {
        return true;
      }
    });
  }
</script>

But the code does not work. urland codewarn correctly. But it javascriptstops executing the jquery function to get content from urland skips the remaining steps in the function.

Please help me find out what is wrong with my code.

Thanks to everyone in advance.

+4
source share
2 answers

ajax , . , captcha "".

: (CORS)

+2

ajax .

http://en.wikipedia.org/wiki/Same_origin_policy

:

XMLHttpRequest http://www.opencaptcha.com/validate.php?img=%27. $captcha_name.% 27.jpgx & ans = hi. "Access-Control-Allow-Origin". http://fiddle.jshell.net ', , .

- , .

.

0

Source: https://habr.com/ru/post/1543356/


All Articles