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>