Created
March 27, 2014 17:01
-
-
Save jshawl/9812543 to your computer and use it in GitHub Desktop.
Ajax instead of captcha?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
<title></title> | |
<meta name="description" content=""> | |
<meta name="viewport" content="width=device-width"> | |
</head> | |
<body> | |
<form action='post.php' method='post'> | |
<input type='text' value='whatever' name='something'> | |
<button type='submit' class='js-submit'>Submit</button> | |
</form> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> | |
<script> | |
$('.js-submit').on('click', function(event){ | |
event.preventDefault(); | |
dataString = 'something='+$('[name="something"]').val(); | |
$.ajax({ | |
type: 'post', | |
url:'post.php', | |
data: dataString + '&human-initiated=true' | |
}).done(function( data ){ | |
console.log(data); | |
}); | |
}); | |
</script> | |
</body> | |
</html><!-- by @jshawl --> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( $_POST['human-initiated']== true ){ | |
echo 'A human submitted this form'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment