如何通过网址确认制作ajax验证码?

I'm trying to make a form in a website. This form works sending with Ajax some data in the url to a php file and showing the response. Is there any way to add a captcha in the url of the ajax and make the php check the captcha? Thanks

My idea of Script:

<script>
    function sleep(milliseconds) {
        var start = new Date().getTime();
        for (var i = 0; i < 1e7; i++) {
            if ((new Date().getTime() - start) > milliseconds) {
                break;
            }
        }
    }

    function loadDoc() {
        var cap = document.getElementById('captcha_code').value
        document.getElementById("captcha_code").value = "";
        var search = document.getElementById('nombre').value
        var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function () {
            if (xhttp.readyState == 4 && xhttp.status == 200) {
                document.getElementById("box").innerHTML = xhttp.responseText;
                sleep(500);
                eval(document.getElementById("runscript").innerHTML);
            }
        };
        xhttp.open("GET", "request.php?nombre=" + escape(search) + "&code=" + cap, true);
        xhttp.send();
    }
</script>

What crap is this?

function sleep(milliseconds) {
    var start = new Date().getTime();
    for (var i = 0; i < 1e7; i++) {
        if ((new Date().getTime() - start) > milliseconds) {
            break;
        }
    }
}

You have something called setTimeout();. Please use that. And if you are using jQuery, please try this:

$.post(url, data, function (resp) {
  // stuff to do when something returns from the server `resp`.
});

To get the captcha code in you PHP file you need to use $_GET('code') instead of GET(reCAPTCHA). You could also check if the permissions the php file has.